Created
February 6, 2014 08:26
-
-
Save snowman-repos/8840270 to your computer and use it in GitHub Desktop.
Manipulating the DOM, without 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
# Select an element | |
element = document.querySelector(".class") | |
# Clone it | |
clone = element.cloneNode(true) | |
# Do some manipulation off the DOM | |
clone.style.background = "#000" | |
# Replaces the original element with the new cloned one | |
element.parentNode.replaceChild clone, element | |
document.body.appendChild clone |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment