Skip to content

Instantly share code, notes, and snippets.

@addyosmani
Forked from Lobstrosity/jqueryPluginPattern.1.js
Created November 30, 2010 06:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save addyosmani/721240 to your computer and use it in GitHub Desktop.
Save addyosmani/721240 to your computer and use it in GitHub Desktop.
(function($) {
$.fn.enable = function() {
// Enable each selected element by removing its 'disabled' attribute.
return this.each(function() {
$(this).removeAttr('disabled');
});
};
$.fn.disable = function() {
return this.each(function() {
// Disable each selected element that is a form control by setting
// its 'disabled' attribute.
if ($(this).is(':input')) {
$(this).attr('disabled', 'disabled');
}
});
};
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment