Created
November 8, 2011 05:10
-
-
Save dtulig/1347059 to your computer and use it in GitHub Desktop.
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
>>> var clNode = document.getElementById('clExample'); | |
>>> clNode.classList | |
// ['red', 'green', 'bold'] | |
>>> clNode.classList.length | |
3 | |
>>> clNode.classList.remove('bold') | |
// Now the classList is ['red', 'green'] | |
>>> clNode.classList.add('emph') | |
// Now the classList is ['red', 'green', 'emph'] | |
>>> clNode.classList.item(0) | |
red // classList.item takes an index. | |
>>> clNode.classList.contains('green') | |
true | |
>>> clNode.classList.toggle('green') | |
// Now the classList is ['red', 'emph'] | |
>>> clNode.classList.toggle('green') | |
// Now the classList is ['red', 'green', 'emph'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment