Skip to content

Instantly share code, notes, and snippets.

@Lobstrosity
Created November 8, 2010 00:08
Show Gist options
  • Save Lobstrosity/667219 to your computer and use it in GitHub Desktop.
Save Lobstrosity/667219 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