Groups
Groups
Sign in
Groups
Groups
Intro to JavaScript
Conversations
About
Send feedback
Help
My solution of Tree Walker
54 views
Skip to first unread message
David Cheung
unread,
Nov 23, 2022, 6:03:41 AM
11/23/22
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Intro to JavaScript
nextNode = function(node) {
//...Code goes here to walk to the next node...
if (node.firstChild !== null) {
node = node.firstChild;
} else if (node.nextSibling !== null) {
node = node.nextSibling;
} else {
var pnode = node.parentNode;
var found = false;
while ( pnode !== null) {
if (pnode.nextSibling !== null) {
node = pnode.nextSibling;
found = true;
break;
}
else {
pnode = pnode.parentNode;
}
}
if (found !== true) { node = null;}
}
return node;
}
Reply all
Reply to author
Forward
0 new messages