Created
February 3, 2017 23:12
-
-
Save ricardozea/4471e3f84db9e992d913383191c855ba to your computer and use it in GitHub Desktop.
toggleAttr() jQuery plugin by Mathias Bynens.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*! | |
* 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/> | |
*/ | |
jQuery.fn.toggleAttr = function(attr) { | |
return this.each(function() { | |
var $this = $(this); | |
$this.attr(attr) ? $this.removeAttr(attr) : $this.attr(attr, attr); | |
}); | |
}; | |
//Usage | |
$(".selector").toggleAttr("disabled"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment