Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

My Solution to TreeWalker

61 views
Skip to first unread message

Michael Wachsman

unread,
Nov 1, 2021, 9:13:01 AM11/1/21
to Intro to JavaScript
nextNode = function(node) {
    if(node.childNodes.length) return node.firstChild; 
    if(node.nextSibling !== null) return node.nextSibling;
    while(node !== null && node.nextSibling === null){
       node = node.parentNode;
    }
    return node.nextSibling;
};
Reply all
Reply to author
Forward
0 new messages