<?xml version='1.0' encoding='ISO-8859-1'?>
<?xml-stylesheet type='text/xsl' href='docs.xsl'?>
<docs>
<method cat='DOM/Traversing' type='jQuery' short='Get a set of elements containing the unique ancestors of the matched
set of elements (except for the root element).' name='parents'>
<desc>Get a set of elements containing the unique ancestors of the matched
set of elements (except for the root element).

The matched elements can be filtered with an optional expression.</desc>
<params type='String' name='expr'>
<desc>(optional) An expression to filter the ancestors with</desc>
</params>
<examples>
<desc>Find all parent elements of each span.</desc>
<before>&lt;html&gt;&lt;body&gt;&lt;div&gt;&lt;p&gt;&lt;span&gt;Hello&lt;/span&gt;&lt;/p&gt;&lt;span&gt;Hello Again&lt;/span&gt;&lt;/div&gt;&lt;/body&gt;&lt;/html&gt;</before>
<code>$("span").parents()</code>
<result>[ &lt;body&gt;...&lt;/body&gt;, &lt;div&gt;...&lt;/div&gt;, &lt;p&gt;&lt;span&gt;Hello&lt;/span&gt;&lt;/p&gt; ]</result>
</examples>
<examples>
<desc>Find all parent elements of each span that is a paragraph.</desc>
<before>&lt;html&gt;&lt;body&gt;&lt;div&gt;&lt;p&gt;&lt;span&gt;Hello&lt;/span&gt;&lt;/p&gt;&lt;span&gt;Hello Again&lt;/span&gt;&lt;/div&gt;&lt;/body&gt;&lt;/html&gt;</before>
<code>$("span").parents("p")</code>
<result>[ &lt;p&gt;&lt;span&gt;Hello&lt;/span&gt;&lt;/p&gt; ]</result>
</examples>
</method></docs>
