Created
March 1, 2010 13:46
-
-
Save Ajnasz/318378 to your computer and use it in GitHub Desktop.
YUI 2 toggleClass
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
YAHOO.util.Dom.toggleClass = function(el, cn) { | |
return YAHOO.util.Dom.hasClass(el, cn) ? YAHOO.util.Dom.removeClass(el, cn) : YAHOO.util.Dom.addClass(el, cn); | |
}; | |
YAHOO.util.Element.prototype.toggleClass = function(cn) { | |
return YAHOO.util.Dom.toggleClass(this.get('element'), cn); | |
}; | |
YAHOO.util.Dom.toggleClass('elementid', 'hidden'); | |
// or | |
var el = new YAHOO.util.Element('elementid'); | |
el.toggleClass('hidden'); |
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
.hidden { | |
display:none; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment