HTML / CSS / JavaScript Tutorial

JavaScript Document own method: querySelectorAll()

[this page | pdf | back links]

The querySelectorAll() method (when applied to the document object of the JavaScript DOM) returns first (child) element that matches specified CSSSelector.


It has the following syntax with the following parameters. It returns a NodeList object representing the first element that matches the specified CSSSelector or if no such element exists it does not return any value. If the selector(s) is invalid then it throws a SYNTAX_ERR exception. The number of such elements can be identified from the length property of the NodeList object, and individual elements can then be accessed using relevant index numbers applied to the NodeList object.





Required / Optional




String specifying one or more CSSSelectors. For multiple selectors, separate each one with a comma.


Contents | Prev | Next | JavaScript DOM (and BOM)

Desktop view | Switch to Mobile