Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to traverse every element of the document using javaScript? [duplicate]

as above. How to traverse every element of the document using javascript?

like image 293
Aleksandra Pawlak Avatar asked Feb 16 '26 01:02

Aleksandra Pawlak


1 Answers

You could select all elements by passing * to getElementsByTagName() like this:

var all = document.getElementsByTagName("*");

for (var i=0; i < all.length; i++) {
    console.log(all[i].nodeName);
}
like image 110
eztam Avatar answered Feb 18 '26 14:02

eztam



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!