Skip to content

Instantly share code, notes, and snippets.

@ajace
Created September 16, 2013 18:45
Show Gist options
  • Save ajace/6584732 to your computer and use it in GitHub Desktop.
Save ajace/6584732 to your computer and use it in GitHub Desktop.
Crockford's WalkTheDom ex: var root = document.getElementById('div'); walkTheDOM(root, function(node) { console.log( node.nodeName ); });
function walkTheDOM(node, func) {
func(node);
node = node.firstChild;
while (node) {
walkTheDOM(node, func);
node = node.nextSibling;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment