Created
June 5, 2015 09:56
-
-
Save ichadhr/515910bd06d54f7b6efd to your computer and use it in GitHub Desktop.
Toggle Attribute jQuery
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
$.fn.toggleAttr = function(a, b) { | |
var c = (b === undefined); | |
return this.each(function() { | |
if((c && !$(this).is("["+a+"]")) || (!c && b)) $(this).attr(a,a); | |
else $(this).removeAttr(a); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment