2 |
aperonnet |
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="../source/core/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).
|
|
|
18 |
<p>
|
|
|
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>
|
|
|
20 |
|
|
|
21 |
<p>
|
|
|
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.
|
|
|
23 |
</p>
|
|
|
24 |
<h4>Element Selectors:</h4>
|
|
|
25 |
<ul class="list">
|
|
|
26 |
<li> <b>*</b> any element</li>
|
|
|
27 |
<li> <b>E</b> an element with the tag E</li>
|
|
|
28 |
<li> <b>E F</b> All descendent elements of E that have the tag F</li>
|
|
|
29 |
<li> <b>E > F</b> or <b>E/F</b> all direct children elements of E that have the tag F</li>
|
|
|
30 |
<li> <b>E + F</b> all elements with the tag F that are immediately preceded by an element with the tag E</li>
|
|
|
31 |
<li> <b>E ~ F</b> all elements with the tag F that are preceded by a sibling element with the tag E</li>
|
|
|
32 |
</ul>
|
|
|
33 |
<h4>Attribute Selectors:</h4>
|
|
|
34 |
<p>The use of @ and quotes are optional. For example, div[@foo='bar'] is also a valid attribute selector.</p>
|
|
|
35 |
<ul class="list">
|
|
|
36 |
<li> <b>E[foo]</b> has an attribute "foo"</li>
|
|
|
37 |
<li> <b>E[foo=bar]</b> has an attribute "foo" that equals "bar"</li>
|
|
|
38 |
<li> <b>E[foo^=bar]</b> has an attribute "foo" that starts with "bar"</li>
|
|
|
39 |
<li> <b>E[foo$=bar]</b> has an attribute "foo" that ends with "bar"</li>
|
|
|
40 |
<li> <b>E[foo*=bar]</b> has an attribute "foo" that contains the substring "bar"</li>
|
|
|
41 |
<li> <b>E[foo%=2]</b> has an attribute "foo" that is evenly divisible by 2</li>
|
|
|
42 |
<li> <b>E[foo!=bar]</b> has an attribute "foo" that does not equal "bar"</li>
|
|
|
43 |
</ul>
|
|
|
44 |
<h4>Pseudo Classes:</h4>
|
|
|
45 |
<ul class="list">
|
|
|
46 |
<li> <b>E:first-child</b> E is the first child of its parent</li>
|
|
|
47 |
<li> <b>E:last-child</b> E is the last child of its parent</li>
|
|
|
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>
|
|
|
49 |
<li> <b>E:nth-child(odd)</b> E is an odd child of its parent</li>
|
|
|
50 |
<li> <b>E:nth-child(even)</b> E is an even child of its parent</li>
|
|
|
51 |
<li> <b>E:only-child</b> E is the only child of its parent</li>
|
|
|
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>
|
|
|
53 |
<li> <b>E:first</b> the first E in the resultset</li>
|
|
|
54 |
<li> <b>E:last</b> the last E in the resultset</li>
|
|
|
55 |
<li> <b>E:nth(<i>n</i>)</b> the <i>n</i>th E in the resultset (1 based)</li>
|
|
|
56 |
<li> <b>E:odd</b> shortcut for :nth-child(odd)</li>
|
|
|
57 |
<li> <b>E:even</b> shortcut for :nth-child(even)</li>
|
|
|
58 |
<li> <b>E:contains(foo)</b> E's innerHTML contains the substring "foo"</li>
|
|
|
59 |
<li> <b>E:nodeValue(foo)</b> E contains a textNode with a nodeValue that equals "foo"</li>
|
|
|
60 |
<li> <b>E:not(S)</b> an E element that does not match simple selector S</li>
|
|
|
61 |
<li> <b>E:has(S)</b> an E element that has a descendent that matches simple selector S</li>
|
|
|
62 |
<li> <b>E:next(S)</b> an E element whose next sibling matches simple selector S</li>
|
|
|
63 |
<li> <b>E:prev(S)</b> an E element whose previous sibling matches simple selector S</li>
|
|
|
64 |
</ul>
|
|
|
65 |
<h4>CSS Value Selectors:</h4>
|
|
|
66 |
<ul class="list">
|
|
|
67 |
<li> <b>E{display=none}</b> css value "display" that equals "none"</li>
|
|
|
68 |
<li> <b>E{display^=none}</b> css value "display" that starts with "none"</li>
|
|
|
69 |
<li> <b>E{display$=none}</b> css value "display" that ends with "none"</li>
|
|
|
70 |
<li> <b>E{display*=none}</b> css value "display" that contains the substring "none"</li>
|
|
|
71 |
<li> <b>E{display%=2}</b> css value "display" that is evenly divisible by 2</li>
|
|
|
72 |
<li> <b>E{display!=none}</b> css value "display" that does not equal "none"</li>
|
|
|
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">
|
|
|
84 |
<td class="micon"><a class="exi" href="#expand"> </a></td>
|
|
|
85 |
<td class="sig">
|
|
|
86 |
<a id="Ext.DomQuery-matchers"></a>
|
|
|
87 |
<b>matchers</b> : Object <div class="mdesc">
|
|
|
88 |
Collection of matching regular expressions and code snippets. </div>
|
|
|
89 |
</td>
|
|
|
90 |
<td class="msource">DomQuery</td>
|
|
|
91 |
</tr>
|
|
|
92 |
<tr class="property-row alt expandable">
|
|
|
93 |
<td class="micon"><a class="exi" href="#expand"> </a></td>
|
|
|
94 |
<td class="sig">
|
|
|
95 |
<a id="Ext.DomQuery-operators"></a>
|
|
|
96 |
<b>operators</b> : Object <div class="mdesc">
|
|
|
97 |
<div class="short">Collection of operator comparison functions. The default operators are =, !=, ^=, $=, *=, %=, |= and ~=.
|
|
|
98 |
New operator...</div>
|
|
|
99 |
<div class="long">
|
|
|
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, > <. </div>
|
|
|
102 |
</div>
|
|
|
103 |
</td>
|
|
|
104 |
<td class="msource">DomQuery</td>
|
|
|
105 |
</tr>
|
|
|
106 |
<tr class="property-row expandable">
|
|
|
107 |
<td class="micon"><a class="exi" href="#expand"> </a></td>
|
|
|
108 |
<td class="sig">
|
|
|
109 |
<a id="Ext.DomQuery-pseudos"></a>
|
|
|
110 |
<b>pseudos</b> : Object <div class="mdesc">
|
|
|
111 |
<div class="short">Collection of "pseudo class" processors. Each processor is passed the current nodeset (array)
|
|
|
112 |
and the argument (if an...</div>
|
|
|
113 |
<div class="long">
|
|
|
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>
|
|
|
116 |
</div>
|
|
|
117 |
</td>
|
|
|
118 |
<td class="msource">DomQuery</td>
|
|
|
119 |
</tr>
|
|
|
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">
|
|
|
129 |
<td class="micon"><a class="exi" href="#expand"> </a></td>
|
|
|
130 |
<td class="sig">
|
|
|
131 |
<a id="Ext.DomQuery-compile"></a>
|
|
|
132 |
<b>compile</b>( <code>String selector</code>, <span class="optional" title="Optional">[<code>String type</code>]</span> ) : Function <div class="mdesc">
|
|
|
133 |
<div class="short">Compiles a selector/xpath query into a reusable function. The returned function
|
|
|
134 |
takes one parameter "root" (optional)...</div>
|
|
|
135 |
<div class="long">
|
|
|
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">
|
|
|
138 |
<strong>Parameters:</strong>
|
|
|
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>
|
|
|
140 |
<strong>Returns:</strong>
|
|
|
141 |
<ul>
|
|
|
142 |
<li><code>Function</code></li>
|
|
|
143 |
</ul>
|
|
|
144 |
</div>
|
|
|
145 |
</div>
|
|
|
146 |
</div>
|
|
|
147 |
</td>
|
|
|
148 |
<td class="msource">DomQuery</td>
|
|
|
149 |
</tr>
|
|
|
150 |
<tr class="method-row alt expandable">
|
|
|
151 |
<td class="micon"><a class="exi" href="#expand"> </a></td>
|
|
|
152 |
<td class="sig">
|
|
|
153 |
<a id="Ext.DomQuery-filter"></a>
|
|
|
154 |
<b>filter</b>( <code>Array el</code>, <code>String selector</code>, <code>Boolean nonMatches</code> ) : Array <div class="mdesc">
|
|
|
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>
|
|
|
156 |
<div class="long">
|
|
|
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">
|
|
|
158 |
<strong>Parameters:</strong>
|
|
|
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>
|
|
|
161 |
<strong>Returns:</strong>
|
|
|
162 |
<ul>
|
|
|
163 |
<li><code>Array</code></li>
|
|
|
164 |
</ul>
|
|
|
165 |
</div>
|
|
|
166 |
</div>
|
|
|
167 |
</div>
|
|
|
168 |
</td>
|
|
|
169 |
<td class="msource">DomQuery</td>
|
|
|
170 |
</tr>
|
|
|
171 |
<tr class="method-row expandable">
|
|
|
172 |
<td class="micon"><a class="exi" href="#expand"> </a></td>
|
|
|
173 |
<td class="sig">
|
|
|
174 |
<a id="Ext.DomQuery-is"></a>
|
|
|
175 |
<b>is</b>( <code>String/HTMLElement/Array el</code>, <code>String selector</code> ) : Boolean <div class="mdesc">
|
|
|
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>
|
|
|
177 |
<div class="long">
|
|
|
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">
|
|
|
179 |
<strong>Parameters:</strong>
|
|
|
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>
|
|
|
181 |
<strong>Returns:</strong>
|
|
|
182 |
<ul>
|
|
|
183 |
<li><code>Boolean</code></li>
|
|
|
184 |
</ul>
|
|
|
185 |
</div>
|
|
|
186 |
</div>
|
|
|
187 |
</div>
|
|
|
188 |
</td>
|
|
|
189 |
<td class="msource">DomQuery</td>
|
|
|
190 |
</tr>
|
|
|
191 |
<tr class="method-row alt expandable">
|
|
|
192 |
<td class="micon"><a class="exi" href="#expand"> </a></td>
|
|
|
193 |
<td class="sig">
|
|
|
194 |
<a id="Ext.DomQuery-select"></a>
|
|
|
195 |
<b>select</b>( <code>String selector</code>, <span class="optional" title="Optional">[<code>Node root</code>]</span> ) : Array <div class="mdesc">
|
|
|
196 |
<div class="short">Selects a group of elements.</div>
|
|
|
197 |
<div class="long">
|
|
|
198 |
Selects a group of elements. <div class="mdetail-params">
|
|
|
199 |
<strong>Parameters:</strong>
|
|
|
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>
|
|
|
201 |
<strong>Returns:</strong>
|
|
|
202 |
<ul>
|
|
|
203 |
<li><code>Array</code></li>
|
|
|
204 |
</ul>
|
|
|
205 |
</div>
|
|
|
206 |
</div>
|
|
|
207 |
</div>
|
|
|
208 |
</td>
|
|
|
209 |
<td class="msource">DomQuery</td>
|
|
|
210 |
</tr>
|
|
|
211 |
<tr class="method-row expandable">
|
|
|
212 |
<td class="micon"><a class="exi" href="#expand"> </a></td>
|
|
|
213 |
<td class="sig">
|
|
|
214 |
<a id="Ext.DomQuery-selectNode"></a>
|
|
|
215 |
<b>selectNode</b>( <code>String selector</code>, <span class="optional" title="Optional">[<code>Node root</code>]</span> ) : Element <div class="mdesc">
|
|
|
216 |
<div class="short">Selects a single element.</div>
|
|
|
217 |
<div class="long">
|
|
|
218 |
Selects a single element. <div class="mdetail-params">
|
|
|
219 |
<strong>Parameters:</strong>
|
|
|
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>
|
|
|
221 |
<strong>Returns:</strong>
|
|
|
222 |
<ul>
|
|
|
223 |
<li><code>Element</code></li>
|
|
|
224 |
</ul>
|
|
|
225 |
</div>
|
|
|
226 |
</div>
|
|
|
227 |
</div>
|
|
|
228 |
</td>
|
|
|
229 |
<td class="msource">DomQuery</td>
|
|
|
230 |
</tr>
|
|
|
231 |
<tr class="method-row alt expandable">
|
|
|
232 |
<td class="micon"><a class="exi" href="#expand"> </a></td>
|
|
|
233 |
<td class="sig">
|
|
|
234 |
<a id="Ext.DomQuery-selectNumber"></a>
|
|
|
235 |
<b>selectNumber</b>( <code>String selector</code>, <span class="optional" title="Optional">[<code>Node root</code>]</span>, <code>Number defaultValue</code> ) : Number <div class="mdesc">
|
|
|
236 |
<div class="short">Selects the value of a node, parsing integers and floats.</div>
|
|
|
237 |
<div class="long">
|
|
|
238 |
Selects the value of a node, parsing integers and floats. <div class="mdetail-params">
|
|
|
239 |
<strong>Parameters:</strong>
|
|
|
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>
|
|
|
241 |
<strong>Returns:</strong>
|
|
|
242 |
<ul>
|
|
|
243 |
<li><code>Number</code></li>
|
|
|
244 |
</ul>
|
|
|
245 |
</div>
|
|
|
246 |
</div>
|
|
|
247 |
</div>
|
|
|
248 |
</td>
|
|
|
249 |
<td class="msource">DomQuery</td>
|
|
|
250 |
</tr>
|
|
|
251 |
<tr class="method-row expandable">
|
|
|
252 |
<td class="micon"><a class="exi" href="#expand"> </a></td>
|
|
|
253 |
<td class="sig">
|
|
|
254 |
<a id="Ext.DomQuery-selectValue"></a>
|
|
|
255 |
<b>selectValue</b>( <code>String selector</code>, <span class="optional" title="Optional">[<code>Node root</code>]</span>, <code>String defaultValue</code> ) : void <div class="mdesc">
|
|
|
256 |
<div class="short">Selects the value of a node, optionally replacing null with the defaultValue.</div>
|
|
|
257 |
<div class="long">
|
|
|
258 |
Selects the value of a node, optionally replacing null with the defaultValue. <div class="mdetail-params">
|
|
|
259 |
<strong>Parameters:</strong>
|
|
|
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>
|
|
|
261 |
<strong>Returns:</strong>
|
|
|
262 |
<ul>
|
|
|
263 |
<li><code>void</code></li>
|
|
|
264 |
</ul>
|
|
|
265 |
</div>
|
|
|
266 |
</div>
|
|
|
267 |
</div>
|
|
|
268 |
</td>
|
|
|
269 |
<td class="msource">DomQuery</td>
|
|
|
270 |
</tr>
|
|
|
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>
|