Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ratbeard/530761 to your computer and use it in GitHub Desktop.
Save ratbeard/530761 to your computer and use it in GitHub Desktop.
/*!
* toggleAttr() jQuery plugin
* @link http://github.com/mathiasbynens/toggleAttr-jQuery-Plugin
* @description Used to toggle selected="selected", disabled="disabled", checked="checked" etc…
* @author Mathias Bynens <http://mathiasbynens.be/>
*/
;(function($) {
$.fn.toggleAttr = function(attr) {
return this.each(function() {
$(this).attr(attr) ? $(this).removeAttr(attr) : $(this).attr(attr, attr);
});
};
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment