Created
November 6, 2015 13:13
-
-
Save robabby/5b7b42e4cc34317d8d70 to your computer and use it in GitHub Desktop.
A simple function to start walking the DOM written in vanilla JS
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
| function walkTheDOM(node) { | |
| if (node.nodeType == 1) { | |
| //console.log(node.tagName); | |
| node = node.firstChild; | |
| while (node) { | |
| theDOMElementWalker(node); | |
| node = node.nextSibling; | |
| } | |
| } | |
| } | |
| var element = document.getElementByTagName('body'); | |
| console.log(walkTheDOM(element)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment