Element.querySelectorAll

  • Revision slug: DOM/Element.querySelectorAll
  • Revision title: Element.querySelectorAll
  • Revision id: 37109
  • Created:
  • Creator: MattBrubeck
  • Is current revision? No
  • Comment link to NodeList; one or more formatting changes

Revision Content

{{ DomRef() }}

{{ gecko_minversion_header("1.9.1") }}

Summary

Returns a list of all elements descended from the element on which it is invoked that match the specified group of selectors.

Syntax

elementList = baseElement.querySelectorAll(selectors);

where

  • elementList is a non-live list of element objects.
  • baseElement is an element object.
  • selectors is a group of selectors to match on.

Example

This example returns a list of all the <code>p</code> elements in the HTML document body:

var matches = document.body.querySelectorAll("p");

Notes

Returns a non-live NodeList of matching elements.

Throws a SYNTAX_ERR exception if the specified group of selectors is invalid.

querySelectorAll() was introduced in the WebApps API.

Specification

See also

Revision Source

<p>{{ DomRef() }}</p>
<p>{{ gecko_minversion_header("1.9.1") }}</p>
<h3 name="Summary">Summary</h3>
<p>Returns a list of all elements descended from the element on which it is invoked that match the specified group of selectors.</p>
<h3 name="Syntax">Syntax</h3>
<pre class="eval"><em>elementList</em> = baseElement.querySelectorAll(<em>selectors</em>);
</pre>
<p>where</p>
<ul> <li><code>elementList</code> is a non-live list of <a class="internal" href="/en/DOM/element" title="En/DOM/Element">element</a> objects.</li> <li><code>baseElement</code> is an <a href="/en/DOM/element" title="en/DOM/element">element</a> object.</li> <li><code>selectors</code> is a group of selectors to match on.</li>
</ul>
<h3 name="Example">Example</h3>
<p>This example returns a list of all the &lt;code&gt;p&lt;/code&gt; elements in the HTML document body:</p>
<pre class="brush: js">var matches = document.body.querySelectorAll("p");
</pre>
<h3 name="Notes">Notes</h3>
<p>Returns a non-live <a href="/En/DOM/NodeList" title="En/DOM/NodeList"><code>NodeList</code></a> of matching elements.</p>
<p>Throws a <code>SYNTAX_ERR</code> exception if the specified group of selectors is invalid.</p>
<p><code>querySelectorAll()</code> was introduced in the WebApps API.</p>
<h3 name="Specification">Specification</h3>
<ul> <li><a class="external" href="http://www.w3.org/TR/selectors-api/" title="http://www.w3.org/TR/selectors-api/">Selectors API</a></li>
</ul>
<h3 name="See_also">See also</h3>
<ul> <li>{{ DOMMeth("querySelector") }}</li> <li><a class="internal" href="/En/DOM/Document.querySelectorAll" title="en/DOM/document.querySelectorAll"><code>document.querySelectorAll</code></a></li> <li><a class="internal" href="/En/DOM/Document.querySelector" title="en/DOM/document.querySelector"><code>document.querySelector</code></a></li> <li><code><a href="/En/Code_snippets/QuerySelector" title="En/Code_snippets/QuerySelector">Code snippets for querySelector</a></code></li>
</ul>
Revert to this revision