The beauty of jQuery is that is extensible. You can easily extend the jQuery function or its alias $.
For e.g.
$.fn.disable = function()
{
return this.each(function()
{
if(typeof this.disabled != 'undefined') this.disabled = true;
}
);
}
The above code creates a function which will disable the element and return the element collections so that you can cascade more jQuery funtions
e.g $("input").disable();
The above code disables all input type elements.
For e.g.
$.fn.disable = function()
{
return this.each(function()
{
if(typeof this.disabled != 'undefined') this.disabled = true;
}
);
}
The above code creates a function which will disable the element and return the element collections so that you can cascade more jQuery funtions
e.g $("input").disable();
The above code disables all input type elements.
Comments