Package | selectors |
Interface | public interface NodeSelector |
Implementors | Document, DocumentFragment, Element |
Introduced in: | DOM 3 Core |
See also
Method | Defined By | ||
---|---|---|---|
Returns the first element that is a descendent of the element on which it is invoked that matches the specified group of selectors. | NodeSelector | ||
Returns a list of all elements descended from the element on which it is invoked that match the specified group of selectors. | NodeSelector |
Selectors API querySelector | () | method |
public function querySelector(selectors:DOMString):Element
Product Versions : | 5.5 6.0 7.0 8.0 as IE7 8.0 as IE8 2.0 3.0 3.5 3.0 3.1 4.0 1.0 2.0 9.62 10.0b |
Introduced in: | DOM 3 Core |
Returns the first element that is a descendent of the element on which it is invoked that matches the specified group of selectors.
Parameters
selectors:DOMString — One or more selectors
|
Element — The first matching Element node within the node’s subtree. If there is no such node, returns null.
|
DOMException — NAMESPACE_ERR: May be raised if the group of selectors include namespace prefixes that need to be resolved.
|
See also
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Selectors API Example</title> </head> <body> <div id="foo"> <p class="warning">This is a sample warning</p> <p class="error">This is a sample error</p> </div> <div id="bar"> <p>...</p> </div> </body> </html>
var x = document.querySelector("#foo, #bar");
Selectors API querySelectorAll | () | method |
public function querySelectorAll(selectors:DOMString):NodeList
Product Versions : | 5.5 6.0 7.0 8.0 as IE7 8.0 as IE8 2.0 3.0 3.5 3.0 3.1 4.0 1.0 2.0 9.62 10.0b |
Introduced in: | DOM 3 Core |
Returns a list of all elements descended from the element on which it is invoked that match the specified group of selectors.
Parameters
selectors:DOMString — One or more selectors
|
NodeList — A NodeList containing all of the matching Element nodes within the node’s subtree, in document order. If there are no such nodes, returns an empty NodeList.
|
DOMException — NAMESPACE_ERR: May be raised if the group of selectors include namespace prefixes that need to be resolved.
|
See also
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Selectors API Example</title> </head> <body> <div id="foo"> <p class="warning">This is a sample warning</p> <p class="error">This is a sample error</p> </div> <div id="bar"> <p>...</p> </div> </body> </html>
var alerts = document.querySelectorAll("p.warning, p.error");