Sun Dial Menu
Menu querySelectorAll
 

document.querySelectorAll

I saw this selector when analysing Bubbling and Capturing.

The syntax for querySelectorAll():

elementList = parentNode.querySelectorAll(selectors);

The element list is an HTML Collection, an array-like list (collection) of HTML elements. (pseudo array)

The usage of querySelectorAll() is helpful if you want to select multiple elements on a page. The elements can be of different specification, they can be tags, ids, classes and more.

The code for Bubbling and Capturing

In the example on my page describing this querySelectorAll() selects ALL elements on the displayed document. As I say on the page I could not show how the Bubbling and Caputuring worked as I need to just select the relevant divs.

The code below selects all elements and adds eventlisteners to them so that when clicked they display their tag names

<script>
  for(let elem of document.querySelectorAll('*')) {
    elem.addEventListener("click", e => alert(`Capturing: ${elem.tagName}`), true);
    elem.addEventListener("click", e => alert(`Bubbling: ${elem.tagName}`));
  }
</script>
</div>

The code above comes from the javascript.info demo for Bubbling and Capturing.

What MDN say

The Document method querySelectorAll() returns a static (not live) NodeList representing a list of the document's elements that match the specified group of selectors.

Top

Links

External Links Disabled.

tempusfugit.me.uk is a non-commercial website. No payment or benefit is gained by the placement of links toother websites.

The External link is disabled to on this page, please visit other pages

Unlike most genealogical research websites tempusfugit.me.uk does not attempt to get you to "sign-up" when you click on one of their links.

This Wikipedia link is disabled.

The link on Wikipedia was to:

External Links Disabled.

tempusfugit.me.uk is a non-commercial website. No payment or benefit is gained by the placement of links to other websites.

The External link is disabled to on this page, please visit other pages

Top

External Links - references

Site design by Tempusfugit Web Design -