Skip to content

Instantly share code, notes, and snippets.

@tobiasmuecksch
Last active November 7, 2023 21:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tobiasmuecksch/2011407 to your computer and use it in GitHub Desktop.
Save tobiasmuecksch/2011407 to your computer and use it in GitHub Desktop.
JavaScript: Walk the DOM (Go through all DOM Elements)
function walkTheDOM(node,func){
func(node);
node = node.firstChild;
while (node){
walkTheDOM(node, func);
node=node.nextSibling;
}
}
@zrajm
Copy link

zrajm commented Nov 7, 2023

This contains a spelling error. The .nextSibling method is spelled with an initial lower case n (not capital N as in the code above).

@tobiasmuecksch
Copy link
Author

@zrajm i fixed the typo. Thanks for your comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment