<?xml version='1.0' encoding='ISO-8859-1'?>
<?xml-stylesheet type='text/xsl' href='docs.xsl'?>
<docs>
<method cat='DOM/Traversing' type='jQuery' short='Removes all elements from the set of matched elements that do not
match the specified expression(s).' name='filter'>
<desc>Removes all elements from the set of matched elements that do not
match the specified expression(s). This method is used to narrow down
the results of a search.

Provide a comma-separated list of expressions to apply multiple filters at once.</desc>
<params type='String' name='expression'>
<desc>Expression(s) to search with.</desc>
</params>
<examples>
<desc>Selects all paragraphs and removes those without a class "selected".</desc>
<before>&lt;p class="selected"&gt;Hello&lt;/p&gt;&lt;p&gt;How are you?&lt;/p&gt;</before>
<code>$("p").filter(".selected")</code>
<result>[ &lt;p class="selected"&gt;Hello&lt;/p&gt; ]</result>
</examples>
<examples>
<desc>Selects all paragraphs and removes those without class "selected" and being the first one.</desc>
<before>&lt;p&gt;Hello&lt;/p&gt;&lt;p&gt;Hello Again&lt;/p&gt;&lt;p class="selected"&gt;And Again&lt;/p&gt;</before>
<code>$("p").filter(".selected, :first")</code>
<result>[ &lt;p&gt;Hello&lt;/p&gt;, &lt;p class="selected"&gt;And Again&lt;/p&gt; ]</result>
</examples>
</method><method cat='DOM/Traversing' type='jQuery' short='Removes all elements from the set of matched elements that do not
pass the specified filter.' name='filter'>
<desc>Removes all elements from the set of matched elements that do not
pass the specified filter. This method is used to narrow down
the results of a search.</desc>
<params type='Function' name='filter'>
<desc>A function to use for filtering</desc>
</params>
<examples>
<desc>Remove all elements that have a child ol element</desc>
<before>&lt;p&gt;&lt;ol&gt;&lt;li&gt;Hello&lt;/li&gt;&lt;/ol&gt;&lt;/p&gt;&lt;p&gt;How are you?&lt;/p&gt;</before>
<code>$("p").filter(function(index) {
  return $("ol", this).length == 0;
})</code>
<result>[ &lt;p&gt;How are you?&lt;/p&gt; ]</result>
</examples>
</method></docs>
