Packageselectors
Interfacepublic interface NodeSelector
Implementors Document, DocumentFragment, Element

Introduced in: DOM 3 Core 

Objects implementing any of the Document, DocumentFragment or Element interfaces, as defined in DOM Level 3 Core, must also implement the NodeSelector interface.

See also

W3C Selectors API


Public Methods
 MethodDefined By
  
Selectors API querySelector(selectors:DOMString):Element
Returns the first element that is a descendent of the element on which it is invoked that matches the specified group of selectors.
NodeSelector
  
Selectors API querySelectorAll(selectors:DOMString):NodeList
Returns a list of all elements descended from the element on which it is invoked that match the specified group of selectors.
NodeSelector
Method Detail
Selectors API querySelector()method
public function querySelector(selectors:DOMString):Element

Product Versions : Internet Explorer 5.5 Internet Explorer 6.0 Internet Explorer 7.0 Internet Explorer 8.0 as IE7 Internet Explorer 8.0 as IE8 Firefox 2.0 Firefox 3.0 Firefox 3.5 Safari 3.0 Safari 3.1 Safari 4.0 Chrome 1.0 Chrome 2.0 Opera 9.62 Opera 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

Returns
Element — The first matching Element node within the node’s subtree. If there is no such node, returns null.

Throws
DOMException — NAMESPACE_ERR: May be raised if the group of selectors include namespace prefixes that need to be resolved.

See also


Example
         <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>
x would contain the first element in the document with an ID of either foo or bar (or both). In the sample document above, it would select the div element with the ID of foo because it is first in document order.
var x = document.querySelector("#foo, #bar");
Selectors API querySelectorAll()method 
public function querySelectorAll(selectors:DOMString):NodeList

Product Versions : Internet Explorer 5.5 Internet Explorer 6.0 Internet Explorer 7.0 Internet Explorer 8.0 as IE7 Internet Explorer 8.0 as IE8 Firefox 2.0 Firefox 3.0 Firefox 3.5 Safari 3.0 Safari 3.1 Safari 4.0 Chrome 1.0 Chrome 2.0 Opera 9.62 Opera 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

Returns
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.

Throws
DOMException — NAMESPACE_ERR: May be raised if the group of selectors include namespace prefixes that need to be resolved.

See also


Example
         <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>
The following example would select all p elements in the document that have a class of either "error" or "warning".
var alerts = document.querySelectorAll("p.warning, p.error");