The code below gets all children within body but it does not get the body element itself. How can I get all child elements including body with pure JavaScipt?
document.querySelectorAll('body *');
You are getting all inner elements of body tag instead use * to get all elements.
document.querySelectorAll('*');
If you want to get body and its all inner elements then use comma separated multiple selectors.
document.querySelectorAll('body,body *');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With