Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

My solution to Tree Walker

194 views
Skip to first unread message

Jennifer Openshaw

unread,
Oct 13, 2020, 9:09:23 AM10/13/20
to Intro to JavaScript
nextNode = function(node) {
  //...Code goes here to walk to the next node...
if (node.childNodes.length !== 0) {
  node = node.firstChild;
    } else if (node.nextSibling !== null) {
    node = node.nextSibling;
    } else if (node.parentNode.nextSibling !== null) {
      node = node.parentNode.nextSibling;
    } else {
    node = node.parentNode.parentNode.nextSibling;
    }
  return node;
};
Reply all
Reply to author
Forward
0 new messages