/

HTML / CSS / JavaScript Tutorial

JavaScript DOM HTML method: querySelectorAll()

[this page | pdf | back links]

The querySelectorAll() method (when applied to HTML elements in 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 CSSSelectoroes 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.

 

element.querySelectorAll(CSSSelectors)

 

Parameter

Required / Optional

Description

CSSSelectors

Required

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

 


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


Desktop view | Switch to Mobile