Languages
[Edit]
EN

JavaScript - find all elements inside web page body

0 points
Created by:
mkrieger1
726

In this article, we would like to show you how to find all elements inside web page body using JavaScript.

Quick solution:

or:

 

Practical examples

Edit

Example 1

Edit

In this example, we create a reusable function that uses querySelectorAll() method on body element with * selector to get the collection of all HTML elements inside the <body>.

Example 2

Edit

In this example, we create a reusable function that uses querySelectorAll() method on with body > * selector to get the collection of all HTML elements inside the <body>.

Note:

The findElements() function needs to be executed after window load event or at the end of the script to make sure that all elements are loaded before the function execution.

 

See also

Edit
  1. JavaScript - find all elements inside web page head element

  2. JavaScript - find all HTML comments

  3. JavaScript - find all links on web page

  4. JavaScript - find all images on web page

References

Edit
  1. Document.querySelectorAll() - Web APIs | MDN
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join