I wrote the following to enable/disable elements, and it works fine.
I then attempted to write one for an array to determine if it contains a specific value, but on call i get error "validStatus.arrayContains is not a function"
I don't understand why my first one works but the other does not.
Thanks for your time.
Code:
jQuery.fn.enable = function (enable) {
var $this = $(this);
if (enable) {
$this.removeAttr("disabled");
}
else {
$this.attr("disabled", "disabled");
}
};
Usage:
var element = $(".someclass");
element.enable(true);
I then attempted to write one for an array to determine if it contains a specific value, but on call i get error "validStatus.arrayContains is not a function"
Code:
jQuery.fn.arrayContains = function (value) {
return jQuery.inArray(value, $(this)) !== -1;
};
Usage:
var validStatus = ["0", "5", "15"];
if (validStatus.arrayContains("10")) {
{
}
I don't understand why my first one works but the other does not.
Thanks for your time.