make sure the README will appear on github
[extjs.git] / docs / output / Ext.DomQuery.html
1         <div class="body-wrap">
2         <div class="top-tools">
3             <a class="inner-link" href="#Ext.DomQuery-props"><img src="../resources/images/default/s.gif" class="item-icon icon-prop">Properties</a>
4             <a class="inner-link" href="#Ext.DomQuery-methods"><img src="../resources/images/default/s.gif" class="item-icon icon-method">Methods</a>
5             <a class="inner-link" href="#Ext.DomQuery-events"><img src="../resources/images/default/s.gif" class="item-icon icon-event">Events</a>
6                         <a class="bookmark" href="../docs/?class=Ext.DomQuery"><img src="../resources/images/default/s.gif" class="item-icon icon-fav">Direct Link</a>
7         </div>
8                 <h1>Class Ext.DomQuery</h1>
9         <table cellspacing="0">
10             <tr><td class="label">Package:</td><td class="hd-info">Ext</td></tr>
11             <tr><td class="label">Defined In:</td><td class="hd-info"><a href="../src/DomQuery.js" target="_blank">DomQuery.js</a></td></tr>
12             <tr><td class="label">Class:</td><td class="hd-info">DomQuery</td></tr>
13                                     <tr><td class="label">Extends:</td><td class="hd-info">Object</td></tr>
14                     </table>
15         <div class="description">
16             *
17 Provides high performance selector/xpath processing by compiling queries into reusable functions. New pseudo classes and matchers can be plugged. It works on HTML and XML documents (if a content node is passed in).\r
18 <p>\r
19 DomQuery supports most of the <a href="http://www.w3.org/TR/2005/WD-css3-selectors-20051215/#selectors">CSS3 selectors spec</a>, along with some custom selectors and basic XPath.</p>\r
20 \r
21 <p>\r
22 All selectors, attribute filters and pseudos below can be combined infinitely in any order. For example "div.foo:nth-child(odd)[@foo=bar].bar:first" would be a perfectly valid selector. Node filters are processed in the order in which they appear, which allows you to optimize your queries for your document structure.\r
23 </p>\r
24 <h4>Element Selectors:</h4>\r
25 <ul class="list">\r
26     <li> <b>*</b> any element</li>\r
27     <li> <b>E</b> an element with the tag E</li>\r
28     <li> <b>E F</b> All descendent elements of E that have the tag F</li>\r
29     <li> <b>E > F</b> or <b>E/F</b> all direct children elements of E that have the tag F</li>\r
30     <li> <b>E + F</b> all elements with the tag F that are immediately preceded by an element with the tag E</li>\r
31     <li> <b>E ~ F</b> all elements with the tag F that are preceded by a sibling element with the tag E</li>\r
32 </ul>\r
33 <h4>Attribute Selectors:</h4>\r
34 <p>The use of @ and quotes are optional. For example, div[@foo='bar'] is also a valid attribute selector.</p>\r
35 <ul class="list">\r
36     <li> <b>E[foo]</b> has an attribute "foo"</li>\r
37     <li> <b>E[foo=bar]</b> has an attribute "foo" that equals "bar"</li>\r
38     <li> <b>E[foo^=bar]</b> has an attribute "foo" that starts with "bar"</li>\r
39     <li> <b>E[foo$=bar]</b> has an attribute "foo" that ends with "bar"</li>\r
40     <li> <b>E[foo*=bar]</b> has an attribute "foo" that contains the substring "bar"</li>\r
41     <li> <b>E[foo%=2]</b> has an attribute "foo" that is evenly divisible by 2</li>\r
42     <li> <b>E[foo!=bar]</b> has an attribute "foo" that does not equal "bar"</li>\r
43 </ul>\r
44 <h4>Pseudo Classes:</h4>\r
45 <ul class="list">\r
46     <li> <b>E:first-child</b> E is the first child of its parent</li>\r
47     <li> <b>E:last-child</b> E is the last child of its parent</li>\r
48     <li> <b>E:nth-child(<i>n</i>)</b> E is the <i>n</i>th child of its parent (1 based as per the spec)</li>\r
49     <li> <b>E:nth-child(odd)</b> E is an odd child of its parent</li>\r
50     <li> <b>E:nth-child(even)</b> E is an even child of its parent</li>\r
51     <li> <b>E:only-child</b> E is the only child of its parent</li>\r
52     <li> <b>E:checked</b> E is an element that is has a checked attribute that is true (e.g. a radio or checkbox) </li>\r
53     <li> <b>E:first</b> the first E in the resultset</li>\r
54     <li> <b>E:last</b> the last E in the resultset</li>\r
55     <li> <b>E:nth(<i>n</i>)</b> the <i>n</i>th E in the resultset (1 based)</li>\r
56     <li> <b>E:odd</b> shortcut for :nth-child(odd)</li>\r
57     <li> <b>E:even</b> shortcut for :nth-child(even)</li>\r
58     <li> <b>E:contains(foo)</b> E's innerHTML contains the substring "foo"</li>\r
59     <li> <b>E:nodeValue(foo)</b> E contains a textNode with a nodeValue that equals "foo"</li>\r
60     <li> <b>E:not(S)</b> an E element that does not match simple selector S</li>\r
61     <li> <b>E:has(S)</b> an E element that has a descendent that matches simple selector S</li>\r
62     <li> <b>E:next(S)</b> an E element whose next sibling matches simple selector S</li>\r
63     <li> <b>E:prev(S)</b> an E element whose previous sibling matches simple selector S</li>\r
64 </ul>\r
65 <h4>CSS Value Selectors:</h4>\r
66 <ul class="list">\r
67     <li> <b>E{display=none}</b> css value "display" that equals "none"</li>\r
68     <li> <b>E{display^=none}</b> css value "display" that starts with "none"</li>\r
69     <li> <b>E{display$=none}</b> css value "display" that ends with "none"</li>\r
70     <li> <b>E{display*=none}</b> css value "display" that contains the substring "none"</li>\r
71     <li> <b>E{display%=2}</b> css value "display" that is evenly divisible by 2</li>\r
72     <li> <b>E{display!=none}</b> css value "display" that does not equal "none"</li>\r
73 </ul><br><br><i>This class is a singleton and cannot be created directly.</i>        </div>
74         
75         <div class="hr"></div>
76                 <a id="Ext.DomQuery-props"></a>
77         <h2>Public Properties</h2>
78                 <table cellspacing="0" class="member-table">
79             <tr>
80                 <th class="sig-header" colspan="2">Property</th>
81                 <th class="msource-header">Defined By</th>
82             </tr>
83                 <tr class="property-row">\r
84         <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>\r
85         <td class="sig">\r
86         <a id="Ext.DomQuery-matchers"></a>\r
87             <b>matchers</b> : Object            <div class="mdesc">\r
88                             Collection of matching regular expressions and code snippets.                        </div>\r
89         </td>\r
90         <td class="msource">DomQuery</td>\r
91     </tr>\r
92         <tr class="property-row alt expandable">\r
93         <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>\r
94         <td class="sig">\r
95         <a id="Ext.DomQuery-operators"></a>\r
96             <b>operators</b> : Object            <div class="mdesc">\r
97                         <div class="short">Collection of operator comparison functions. The default operators are =, !=, ^=, $=, *=, %=, |= and ~=.
98 New operator...</div>\r
99             <div class="long">\r
100                 Collection of operator comparison functions. The default operators are =, !=, ^=, $=, *=, %=, |= and ~=.
101 New operators can be added as long as the match the format <i>c</i>= where <i>c</i> is any character other than space, &gt; &lt;.            </div>\r
102                         </div>\r
103         </td>\r
104         <td class="msource">DomQuery</td>\r
105     </tr>\r
106         <tr class="property-row expandable">\r
107         <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>\r
108         <td class="sig">\r
109         <a id="Ext.DomQuery-pseudos"></a>\r
110             <b>pseudos</b> : Object            <div class="mdesc">\r
111                         <div class="short">Collection of "pseudo class" processors. Each processor is passed the current nodeset (array)
112 and the argument (if an...</div>\r
113             <div class="long">\r
114                 Collection of "pseudo class" processors. Each processor is passed the current nodeset (array)
115 and the argument (if any) supplied in the selector.            </div>\r
116                         </div>\r
117         </td>\r
118         <td class="msource">DomQuery</td>\r
119     </tr>\r
120             </table>
121                 <a id="Ext.DomQuery-methods"></a>
122         <h2>Public Methods</h2>
123                 <table cellspacing="0" class="member-table">
124             <tr>
125                 <th class="sig-header" colspan="2">Method</th>
126                 <th class="msource-header">Defined By</th>
127             </tr>
128                 <tr class="method-row expandable">\r
129         <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>\r
130         <td class="sig">\r
131         <a id="Ext.DomQuery-compile"></a>\r
132             <b>compile</b>(&nbsp;<code>String selector</code>, <span class="optional" title="Optional">[<code>String type</code>]</span>&nbsp;) : Function            <div class="mdesc">\r
133                         <div class="short">Compiles a selector/xpath query into a reusable function. The returned function
134 takes one parameter "root" (optional)...</div>\r
135             <div class="long">\r
136                 Compiles a selector/xpath query into a reusable function. The returned function
137 takes one parameter "root" (optional), which is the context node from where the query should start.    <div class="mdetail-params">\r
138         <strong>Parameters:</strong>\r
139         <ul><li><code>selector</code> : String<div class="sub-desc">The selector/xpath query</div></li><li><code>type</code> : String<div class="sub-desc">(optional) Either "select" (the default) or "simple" for a simple selector match</div></li>        </ul>\r
140         <strong>Returns:</strong>\r
141         <ul>\r
142             <li><code>Function</code></li>\r
143         </ul>\r
144     </div>\r
145                 </div>\r
146                         </div>\r
147         </td>\r
148         <td class="msource">DomQuery</td>\r
149     </tr>\r
150         <tr class="method-row alt expandable">\r
151         <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>\r
152         <td class="sig">\r
153         <a id="Ext.DomQuery-filter"></a>\r
154             <b>filter</b>(&nbsp;<code>Array el</code>, <code>String selector</code>, <code>Boolean nonMatches</code>&nbsp;) : Array            <div class="mdesc">\r
155                         <div class="short">Filters an array of elements to only include matches of a simple selector (e.g. div.some-class or span:first-child)</div>\r
156             <div class="long">\r
157                 Filters an array of elements to only include matches of a simple selector (e.g. div.some-class or span:first-child)    <div class="mdetail-params">\r
158         <strong>Parameters:</strong>\r
159         <ul><li><code>el</code> : Array<div class="sub-desc">An array of elements to filter</div></li><li><code>selector</code> : String<div class="sub-desc">The simple selector to test</div></li><li><code>nonMatches</code> : Boolean<div class="sub-desc">If true, it returns the elements that DON'T match
160 the selector instead of the ones that match</div></li>        </ul>\r
161         <strong>Returns:</strong>\r
162         <ul>\r
163             <li><code>Array</code><div class="sub-desc">An Array of DOM elements which match the selector. If there are no matches, and empty Array is returned.</div></li>\r
164         </ul>\r
165     </div>\r
166                 </div>\r
167                         </div>\r
168         </td>\r
169         <td class="msource">DomQuery</td>\r
170     </tr>\r
171         <tr class="method-row expandable">\r
172         <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>\r
173         <td class="sig">\r
174         <a id="Ext.DomQuery-is"></a>\r
175             <b>is</b>(&nbsp;<code>String/HTMLElement/Array el</code>, <code>String selector</code>&nbsp;) : Boolean            <div class="mdesc">\r
176                         <div class="short">Returns true if the passed element(s) match the passed simple selector (e.g. div.some-class or span:first-child)</div>\r
177             <div class="long">\r
178                 Returns true if the passed element(s) match the passed simple selector (e.g. div.some-class or span:first-child)    <div class="mdetail-params">\r
179         <strong>Parameters:</strong>\r
180         <ul><li><code>el</code> : String/HTMLElement/Array<div class="sub-desc">An element id, element or array of elements</div></li><li><code>selector</code> : String<div class="sub-desc">The simple selector to test</div></li>        </ul>\r
181         <strong>Returns:</strong>\r
182         <ul>\r
183             <li><code>Boolean</code></li>\r
184         </ul>\r
185     </div>\r
186                 </div>\r
187                         </div>\r
188         </td>\r
189         <td class="msource">DomQuery</td>\r
190     </tr>\r
191         <tr class="method-row alt expandable">\r
192         <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>\r
193         <td class="sig">\r
194         <a id="Ext.DomQuery-select"></a>\r
195             <b>select</b>(&nbsp;<code>String selector</code>, <span class="optional" title="Optional">[<code>Node root</code>]</span>&nbsp;) : Array            <div class="mdesc">\r
196                         <div class="short">Selects a group of elements.</div>\r
197             <div class="long">\r
198                 Selects a group of elements.    <div class="mdetail-params">\r
199         <strong>Parameters:</strong>\r
200         <ul><li><code>selector</code> : String<div class="sub-desc">The selector/xpath query (can be a comma separated list of selectors)</div></li><li><code>root</code> : Node<div class="sub-desc">(optional) The start of the query (defaults to document).</div></li>        </ul>\r
201         <strong>Returns:</strong>\r
202         <ul>\r
203             <li><code>Array</code><div class="sub-desc">An Array of DOM elements which match the selector. If there are no matches, and empty Array is returned.</div></li>\r
204         </ul>\r
205     </div>\r
206                 </div>\r
207                         </div>\r
208         </td>\r
209         <td class="msource">DomQuery</td>\r
210     </tr>\r
211         <tr class="method-row expandable">\r
212         <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>\r
213         <td class="sig">\r
214         <a id="Ext.DomQuery-selectNode"></a>\r
215             <b>selectNode</b>(&nbsp;<code>String selector</code>, <span class="optional" title="Optional">[<code>Node root</code>]</span>&nbsp;) : Element            <div class="mdesc">\r
216                         <div class="short">Selects a single element.</div>\r
217             <div class="long">\r
218                 Selects a single element.    <div class="mdetail-params">\r
219         <strong>Parameters:</strong>\r
220         <ul><li><code>selector</code> : String<div class="sub-desc">The selector/xpath query</div></li><li><code>root</code> : Node<div class="sub-desc">(optional) The start of the query (defaults to document).</div></li>        </ul>\r
221         <strong>Returns:</strong>\r
222         <ul>\r
223             <li><code>Element</code><div class="sub-desc">The DOM element which matched the selector.</div></li>\r
224         </ul>\r
225     </div>\r
226                 </div>\r
227                         </div>\r
228         </td>\r
229         <td class="msource">DomQuery</td>\r
230     </tr>\r
231         <tr class="method-row alt expandable">\r
232         <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>\r
233         <td class="sig">\r
234         <a id="Ext.DomQuery-selectNumber"></a>\r
235             <b>selectNumber</b>(&nbsp;<code>String selector</code>, <span class="optional" title="Optional">[<code>Node root</code>]</span>, <code>Number defaultValue</code>&nbsp;) : Number            <div class="mdesc">\r
236                         <div class="short">Selects the value of a node, parsing integers and floats. Returns the defaultValue, or 0 if none is specified.</div>\r
237             <div class="long">\r
238                 Selects the value of a node, parsing integers and floats. Returns the defaultValue, or 0 if none is specified.    <div class="mdetail-params">\r
239         <strong>Parameters:</strong>\r
240         <ul><li><code>selector</code> : String<div class="sub-desc">The selector/xpath query</div></li><li><code>root</code> : Node<div class="sub-desc">(optional) The start of the query (defaults to document).</div></li><li><code>defaultValue</code> : Number<div class="sub-desc"></div></li>        </ul>\r
241         <strong>Returns:</strong>\r
242         <ul>\r
243             <li><code>Number</code></li>\r
244         </ul>\r
245     </div>\r
246                 </div>\r
247                         </div>\r
248         </td>\r
249         <td class="msource">DomQuery</td>\r
250     </tr>\r
251         <tr class="method-row expandable">\r
252         <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>\r
253         <td class="sig">\r
254         <a id="Ext.DomQuery-selectValue"></a>\r
255             <b>selectValue</b>(&nbsp;<code>String selector</code>, <span class="optional" title="Optional">[<code>Node root</code>]</span>, <code>String defaultValue</code>&nbsp;) : String            <div class="mdesc">\r
256                         <div class="short">Selects the value of a node, optionally replacing null with the defaultValue.</div>\r
257             <div class="long">\r
258                 Selects the value of a node, optionally replacing null with the defaultValue.    <div class="mdetail-params">\r
259         <strong>Parameters:</strong>\r
260         <ul><li><code>selector</code> : String<div class="sub-desc">The selector/xpath query</div></li><li><code>root</code> : Node<div class="sub-desc">(optional) The start of the query (defaults to document).</div></li><li><code>defaultValue</code> : String<div class="sub-desc"></div></li>        </ul>\r
261         <strong>Returns:</strong>\r
262         <ul>\r
263             <li><code>String</code></li>\r
264         </ul>\r
265     </div>\r
266                 </div>\r
267                         </div>\r
268         </td>\r
269         <td class="msource">DomQuery</td>\r
270     </tr>\r
271             </table>
272                 <a id="Ext.DomQuery-events"></a>
273         <h2>Public Events</h2>
274         <div class="no-members">This class has no public events.</div>
275         </div>