1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7 <meta http-equiv="content-type" content="text/html; charset=undefined" />
8 <meta name="generator" content="JsDoc Toolkit" />
11 <title>JsDoc Reference - Roo.DomQuery</title>
14 <link rel="stylesheet" type="text/css" href="../../css/roojs.css" />
15 <link rel="stylesheet" type="text/css" href="../default.css" />
18 <script type="text/javascript" src="../page.js">
25 <body onload="RooDocsPage.onload();">
28 <div class="body-wrap">
30 <!-- ============================== links to methods. ================================= -->
32 <div class="top-tools">
34 <a class="inner-link" href="#Roo.DomQuery-props"><img src="resources/s.gif" class="item-icon icon-prop">Properties</a>
35 <a class="inner-link" href="#Roo.DomQuery-methods"><img src="resources/s.gif" class="item-icon icon-method">Methods</a>
36 <a class="inner-link" href="#Roo.DomQuery-events"><img src="resources/s.gif" class="item-icon icon-event">Events</a>
37 <a class="inner-link" href="#Roo.DomQuery-configs"><img src="resources/s.gif" class="item-icon icon-config">Config Options</a>
38 <a class="bookmark" href="NEED_TO_CREATE_DIRECT_LINK_HREF"><img src="resources/s.gif" class="item-icon icon-fav">Direct Link</a>
43 <!-- ============================== inheritance Block. ================================= -->
45 <!-- ============================== class title / details ============================ -->
48 <h1 class="classTitle">
53 <table cellspacing="0" class="class-summary-table">
55 <tr><td class="label">Package:</td><td class="hd-info">Roo</td></tr>
57 <tr><td class="label">Defined In:</td><td class="hd-info">
59 <a href="./src/Roo_DomQuery.js.html">Roo/DomQuery.js</a>.
62 <tr><td class="label">Class:</td><td class="hd-info">DomQuery</td></tr>
70 <!-- ============================== class summary ========================== -->
71 <div class="description">
72 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).<br/><p><br/>DomQuery supports most of the <a href="http://www.w3.org/TR/2005/WD-css3-selectors-20051215/">CSS3 selectors spec</a>, along with some custom selectors and basic XPath.</p><br/><br/><p><br/>All selectors, attribute filters and pseudos below can be combined infinitely in any order. For example "div.foo:nth-child(odd)[<b>foo</b>=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.<br/></p><br/><h4>Element Selectors:</h4><br/><ul class="list"><br/> <li> <b>*</b> any element</li><br/> <li> <b>E</b> an element with the tag E</li><br/> <li> <b>E F</b> All descendent elements of E that have the tag F</li><br/> <li> <b>E > F</b> or <b>E/F</b> all direct children elements of E that have the tag F</li><br/> <li> <b>E + F</b> all elements with the tag F that are immediately preceded by an element with the tag E</li><br/> <li> <b>E ~ F</b> all elements with the tag F that are preceded by a sibling element with the tag E</li><br/></ul><br/><h4>Attribute Selectors:</h4><br/><p>The use of @ and quotes are optional. For example, div[<b>foo</b>='bar'] is also a valid attribute selector.</p><br/><ul class="list"><br/> <li> <b>E[foo]</b> has an attribute "foo"</li><br/> <li> <b>E[foo=bar]</b> has an attribute "foo" that equals "bar"</li><br/> <li> <b>E[foo^=bar]</b> has an attribute "foo" that starts with "bar"</li><br/> <li> <b>E[foo$=bar]</b> has an attribute "foo" that ends with "bar"</li><br/> <li> <b>E[foo*=bar]</b> has an attribute "foo" that contains the substring "bar"</li><br/> <li> <b>E[foo%=2]</b> has an attribute "foo" that is evenly divisible by 2</li><br/> <li> <b>E[foo!=bar]</b> has an attribute "foo" that does not equal "bar"</li><br/></ul><br/><h4>Pseudo Classes:</h4><br/><ul class="list"><br/> <li> <b>E:first-child</b> E is the first child of its parent</li><br/> <li> <b>E:last-child</b> E is the last child of its parent</li><br/> <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><br/> <li> <b>E:nth-child(odd)</b> E is an odd child of its parent</li><br/> <li> <b>E:nth-child(even)</b> E is an even child of its parent</li><br/> <li> <b>E:only-child</b> E is the only child of its parent</li><br/> <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><br/> <li> <b>E:first</b> the first E in the resultset</li><br/> <li> <b>E:last</b> the last E in the resultset</li><br/> <li> <b>E:nth(<i>n</i>)</b> the <i>n</i>th E in the resultset (1 based)</li><br/> <li> <b>E:odd</b> shortcut for :nth-child(odd)</li><br/> <li> <b>E:even</b> shortcut for :nth-child(even)</li><br/> <li> <b>E:contains(foo)</b> E's innerHTML contains the substring "foo"</li><br/> <li> <b>E:nodeValue(foo)</b> E contains a textNode with a nodeValue that equals "foo"</li><br/> <li> <b>E:not(S)</b> an E element that does not match simple selector S</li><br/> <li> <b>E:has(S)</b> an E element that has a descendent that matches simple selector S</li><br/> <li> <b>E:next(S)</b> an E element whose next sibling matches simple selector S</li><br/> <li> <b>E:prev(S)</b> an E element whose previous sibling matches simple selector S</li><br/></ul><br/><h4>CSS Value Selectors:</h4><br/><ul class="list"><br/> <li> <b>E{display=none}</b> css value "display" that equals "none"</li><br/> <li> <b>E{display^=none}</b> css value "display" that starts with "none"</li><br/> <li> <b>E{display$=none}</b> css value "display" that ends with "none"</li><br/> <li> <b>E{display*=none}</b> css value "display" that contains the substring "none"</li><br/> <li> <b>E{display%=2}</b> css value "display" that is evenly divisible by 2</li><br/> <li> <b>E{display!=none}</b> css value "display" that does not equal "none"</li><br/></ul>
76 <!-- ============================== Class comment block... ========================== -->
78 <div class="comments">
79 <b>Class Comments / Notes</B> =>
80 <u onclick="parent.CommentDialog.showCommentId = 'Roo.DomQuery';">[Add Your comment/notes about this class]</u>
82 <iframe frameborder="0" id="comments-Roo" style="border: none;width:100%;"
83 src="/blog.php/GtkDjsComments/Roo.DomQuery.html"></iframe>
88 <!-- ============================== config options ========================== -->
93 <div class="hr"></div>
94 <a id="Roo.DomQuery-configs"></a>
98 <table cellspacing="0" class="member-table">
99 <caption class="Empty">Config Options - Has None</caption>
113 <!-- ============================== public properties ==================== -->
117 <a id="Roo.DomQuery-props"></a>
123 <table cellspacing="0" class="member-table">
124 <caption class="Empty">Public Properties - Has None</caption>
130 <!-- ============================== methods summary / details ======================== -->
133 <a id="Roo.DomQuery-methods"></a>
134 <!-- constructor?? -->
141 <!-- then dynamics first -->
148 <table cellspacing="0" class="member-table">
149 <caption>Public Methods</caption>
151 <th class="sig-header" colspan="2">Method</th>
152 <th class="msource-header">Defined By</th>
162 <tr class="method-row config-row-alt0 expandable notInherited">
163 <td class="micon"><a class="exi" href="#expand"> </a></td>
167 <a id="Roo.DomQuery-method-compile" name=".compile"></a>
168 <div class="fixedFont">
169 <span class="attributes">Roo.DomQuery.</span><b class="itemname">compile</b>
171 (<a href="./String.html#constructor" roo:cls="String.html#constructor">String</a> <B><i>selector</i></B>, <a href="./String.html#constructor" roo:cls="String.html#constructor">String</a> <B><i>type</i></B>)
177 <a href="./Function.html#constructor" roo:cls="Function.html#constructor">Function</a>
186 <div class="short">Compiles a selector/xpath query into a reusable function.</div>
192 Compiles a selector/xpath query into a reusable function. The returned function<br/>takes one parameter "root" (optional), which is the context node from where the query should start.
199 <dl class="detailList">
200 <dt class="heading">Parameters:</dt>
203 <span class="fixedFont"><a href="./String.html#constructor" roo:cls="String.html#constructor">String</a></span> <b>selector</b>
206 <dd>The selector/xpath query</dd>
209 <span class="fixedFont"><a href="./String.html#constructor" roo:cls="String.html#constructor">String</a></span> <b>type</b>
212 <dd>(optional) Either "select" (the default) or "simple" for a simple selector match</dd>
220 <dl class="detailList">
221 <dt class="heading">Returns:</dt>
223 <dd><span class="fixedFont"><a href="./Function.html#constructor" roo:cls="Function.html#constructor">Function</a></span> </dd>
245 <tr class="method-row config-row-alt1 expandable notInherited">
246 <td class="micon"><a class="exi" href="#expand"> </a></td>
250 <a id="Roo.DomQuery-method-filter" name=".filter"></a>
251 <div class="fixedFont">
252 <span class="attributes">Roo.DomQuery.</span><b class="itemname">filter</b>
254 (<a href="./Array.html#constructor" roo:cls="Array.html#constructor">Array</a> <B><i>el</i></B>, <a href="./String.html#constructor" roo:cls="String.html#constructor">String</a> <B><i>selector</i></B>, <a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Boolean">Boolean</a> <B><i>nonMatches</i></B>)
260 <a href="./Array.html#constructor" roo:cls="Array.html#constructor">Array</a>
269 <div class="short">Filters an array of elements to only include matches of a simple selector (e.g.</div>
275 Filters an array of elements to only include matches of a simple selector (e.g. div.some-class or span:first-child)
282 <dl class="detailList">
283 <dt class="heading">Parameters:</dt>
286 <span class="fixedFont"><a href="./Array.html#constructor" roo:cls="Array.html#constructor">Array</a></span> <b>el</b>
289 <dd>An array of elements to filter</dd>
292 <span class="fixedFont"><a href="./String.html#constructor" roo:cls="String.html#constructor">String</a></span> <b>selector</b>
295 <dd>The simple selector to test</dd>
298 <span class="fixedFont"><a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Boolean">Boolean</a></span> <b>nonMatches</b>
301 <dd>If true, it returns the elements that DON'T match<br/>the selector instead of the ones that match</dd>
309 <dl class="detailList">
310 <dt class="heading">Returns:</dt>
312 <dd><span class="fixedFont"><a href="./Array.html#constructor" roo:cls="Array.html#constructor">Array</a></span> </dd>
334 <tr class="method-row config-row-alt0 expandable notInherited">
335 <td class="micon"><a class="exi" href="#expand"> </a></td>
339 <a id="Roo.DomQuery-method-is" name=".is"></a>
340 <div class="fixedFont">
341 <span class="attributes">Roo.DomQuery.</span><b class="itemname">is</b>
343 (<a href="./String.html#constructor" roo:cls="String.html#constructor">String</a>/HTMLElement/Array <B><i>el</i></B>, <a href="./String.html#constructor" roo:cls="String.html#constructor">String</a> <B><i>selector</i></B>)
349 <a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Boolean">Boolean</a>
358 <div class="short">Returns true if the passed element(s) match the passed simple selector (e.g.</div>
364 Returns true if the passed element(s) match the passed simple selector (e.g. div.some-class or span:first-child)
371 <dl class="detailList">
372 <dt class="heading">Parameters:</dt>
375 <span class="fixedFont"><a href="./String.html#constructor" roo:cls="String.html#constructor">String</a>/HTMLElement/Array</span> <b>el</b>
378 <dd>An element id, element or array of elements</dd>
381 <span class="fixedFont"><a href="./String.html#constructor" roo:cls="String.html#constructor">String</a></span> <b>selector</b>
384 <dd>The simple selector to test</dd>
392 <dl class="detailList">
393 <dt class="heading">Returns:</dt>
395 <dd><span class="fixedFont"><a href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Boolean">Boolean</a></span> </dd>
417 <tr class="method-row config-row-alt1 expandable notInherited">
418 <td class="micon"><a class="exi" href="#expand"> </a></td>
422 <a id="Roo.DomQuery-method-select" name=".select"></a>
423 <div class="fixedFont">
424 <span class="attributes">Roo.DomQuery.</span><b class="itemname">select</b>
426 (<a href="./String.html#constructor" roo:cls="String.html#constructor">String</a> <B><i>selector</i></B>, Node <B><i>root</i></B>)
432 <a href="./Array.html#constructor" roo:cls="Array.html#constructor">Array</a>
441 <div class="short">Selects a group of elements.</div>
447 Selects a group of elements.
454 <dl class="detailList">
455 <dt class="heading">Parameters:</dt>
458 <span class="fixedFont"><a href="./String.html#constructor" roo:cls="String.html#constructor">String</a></span> <b>selector</b>
461 <dd>The selector/xpath query (can be a comma separated list of selectors)</dd>
464 <span class="fixedFont">Node</span> <b>root</b>
467 <dd>(optional) The start of the query (defaults to document).</dd>
475 <dl class="detailList">
476 <dt class="heading">Returns:</dt>
478 <dd><span class="fixedFont"><a href="./Array.html#constructor" roo:cls="Array.html#constructor">Array</a></span> </dd>
500 <tr class="method-row config-row-alt0 expandable notInherited">
501 <td class="micon"><a class="exi" href="#expand"> </a></td>
505 <a id="Roo.DomQuery-method-selectNode" name=".selectNode"></a>
506 <div class="fixedFont">
507 <span class="attributes">Roo.DomQuery.</span><b class="itemname">selectNode</b>
509 (<a href="./String.html#constructor" roo:cls="String.html#constructor">String</a> <B><i>selector</i></B>, Node <B><i>root</i></B>)
524 <div class="short">Selects a single element.</div>
530 Selects a single element.
537 <dl class="detailList">
538 <dt class="heading">Parameters:</dt>
541 <span class="fixedFont"><a href="./String.html#constructor" roo:cls="String.html#constructor">String</a></span> <b>selector</b>
544 <dd>The selector/xpath query</dd>
547 <span class="fixedFont">Node</span> <b>root</b>
550 <dd>(optional) The start of the query (defaults to document).</dd>
558 <dl class="detailList">
559 <dt class="heading">Returns:</dt>
561 <dd><span class="fixedFont">Element</span> </dd>
583 <tr class="method-row config-row-alt1 expandable notInherited">
584 <td class="micon"><a class="exi" href="#expand"> </a></td>
588 <a id="Roo.DomQuery-method-selectNumber" name=".selectNumber"></a>
589 <div class="fixedFont">
590 <span class="attributes">Roo.DomQuery.</span><b class="itemname">selectNumber</b>
592 (<a href="./String.html#constructor" roo:cls="String.html#constructor">String</a> <B><i>selector</i></B>, Node <B><i>root</i></B>, <a href="./Number.html#constructor" roo:cls="Number.html#constructor">Number</a> <B><i>defaultValue</i></B>)
598 <a href="./Number.html#constructor" roo:cls="Number.html#constructor">Number</a>
607 <div class="short">Selects the value of a node, parsing integers and floats.</div>
613 Selects the value of a node, parsing integers and floats.
620 <dl class="detailList">
621 <dt class="heading">Parameters:</dt>
624 <span class="fixedFont"><a href="./String.html#constructor" roo:cls="String.html#constructor">String</a></span> <b>selector</b>
627 <dd>The selector/xpath query</dd>
630 <span class="fixedFont">Node</span> <b>root</b>
633 <dd>(optional) The start of the query (defaults to document).</dd>
636 <span class="fixedFont"><a href="./Number.html#constructor" roo:cls="Number.html#constructor">Number</a></span> <b>defaultValue</b>
647 <dl class="detailList">
648 <dt class="heading">Returns:</dt>
650 <dd><span class="fixedFont"><a href="./Number.html#constructor" roo:cls="Number.html#constructor">Number</a></span> </dd>
672 <tr class="method-row config-row-alt0 expandable notInherited">
673 <td class="micon"><a class="exi" href="#expand"> </a></td>
677 <a id="Roo.DomQuery-method-selectValue" name=".selectValue"></a>
678 <div class="fixedFont">
679 <span class="attributes">Roo.DomQuery.</span><b class="itemname">selectValue</b>
681 (<a href="./String.html#constructor" roo:cls="String.html#constructor">String</a> <B><i>selector</i></B>, Node <B><i>root</i></B>, <a href="./String.html#constructor" roo:cls="String.html#constructor">String</a> <B><i>defaultValue</i></B>)
688 <div class="short">Selects the value of a node, optionally replacing null with the defaultValue.</div>
694 Selects the value of a node, optionally replacing null with the defaultValue.
701 <dl class="detailList">
702 <dt class="heading">Parameters:</dt>
705 <span class="fixedFont"><a href="./String.html#constructor" roo:cls="String.html#constructor">String</a></span> <b>selector</b>
708 <dd>The selector/xpath query</dd>
711 <span class="fixedFont">Node</span> <b>root</b>
714 <dd>(optional) The start of the query (defaults to document).</dd>
717 <span class="fixedFont"><a href="./String.html#constructor" roo:cls="String.html#constructor">String</a></span> <b>defaultValue</b>
749 <!-- ============================== events summary / details ======================== -->
752 <a id="Roo.DomQuery-events"></a>
758 <table cellspacing="0" class="member-table">
759 <caption class="Empty">Events - Has None</caption>
770 <!-- ============================== footer ================================= -->
771 <div class="fineprint" style="clear:both">
773 Documentation generated by <a href="http://www.akbkhome.com" target="_blankt">Introspection Doc Generator</a> on Tue Apr 01 2014 13:11:05 GMT+0800 (HKT)
775 <a href="http://www.jsdoctoolkit.org/" target="_blank">JsDoc Toolkit</a>