0

I tried using document.getElementByTag(“*”); but it doesn’t work for every webpage.

2 Answers 2

1

To select every element you need getElementsByTagName, not getElementByTag.

var elements = document.body.getElementsByTagName("*");
Sign up to request clarification or add additional context in comments.

1 Comment

@Alessio Cantarella Thanks
1

You can use querySelectorAll.

var elements = document.querySelectorAll( 'body *' );

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.