Created
December 11, 2022 14:12
-
-
Save 0187773933/61116cfe2ce14bdd2f2af009e53c4263 to your computer and use it in GitHub Desktop.
Javascript - Traverse Down through A DOM Node
This file contains hidden or 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
let prompt_elements = [ ...document.querySelectorAll( ".stack__answer-question" )[ 0 ].querySelectorAll( "p" ) ]; | |
let tree_walker = document.createTreeWalker( prompt_elements[ 2 ] , NodeFilter.SHOW_ALL , { | |
acceptNode: function ( node ) { | |
return NodeFilter.FILTER_ACCEPT; | |
} | |
} , false ); | |
let done = false; | |
while( done === false ) { | |
let next_node = tree_walker.nextNode(); | |
if ( !next_node ) { done = true; } | |
console.log( next_node ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.