Forked from mathiasbynens/toggleAttr() jQuery plugin
Last active
August 7, 2023 14:33
-
-
Save kadimi/11067674 to your computer and use it in GitHub Desktop.
Toggle checked, selected, disabled, checked, readonly, multiple, etc…
This file contains hidden or 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 | |
* | |
* Toggle checked, selected, disabled, checked, readonly, multiple, etc… | |
*/ | |
jQuery.fn.toggleAttr = function (attr) { | |
return this.each(function () { | |
var $this = $(this); | |
if ($this.attr(attr)) { | |
$this.removeAttr(attr); | |
} else { | |
$this.attr(attr, attr); | |
} | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment