Created
October 8, 2010 11:49
-
-
Save jnslxndr/616668 to your computer and use it in GitHub Desktop.
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
// traverse a given DOM Node and log it's children recursively | |
function logChildNodes(node){ | |
for (var c=0; c<node.childNodes.length; c++){ | |
if (node.childNodes[c].nodeName!='#text') | |
console.log(node.childNodes[c].nodeName+", "+node.childNodes[c].id) | |
if (node.hasChildNodes()) | |
logChildNodes(node.childNodes[c]) | |
} | |
} | |
// for example: | |
logChildNodes(document); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment