Skip to content

Instantly share code, notes, and snippets.

@snowman-repos
Created February 6, 2014 08:26
Show Gist options
  • Save snowman-repos/8840270 to your computer and use it in GitHub Desktop.
Save snowman-repos/8840270 to your computer and use it in GitHub Desktop.
Manipulating the DOM, without jQuery
# 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