Last active
November 7, 2023 21:31
-
-
Save tobiasmuecksch/2011407 to your computer and use it in GitHub Desktop.
JavaScript: Walk the DOM (Go through all DOM Elements)
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
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
This contains a spelling error. The
.nextSibling
method is spelled with an initial lower casen
(not capitalN
as in the code above).