jQuery filter method


jQuery filter method() is used to get elements that match the specified pattern.


Syntax : jQuery filter method

$(selector).filter(criteria,function(index));

Criteria:
– Selector expression to match the current set of elements.
Function:
– Function used to run for each elements. this represents current DOM.

jQuery filter method Example

jQuery filter() Method Example with syntax

<script type="text/javascript">// <![CDATA[
         $(document).ready(function(){ 
             $("li").filter(":odd").css("background","yellow");
             $("li").filter(":even").css("border","1px solid red");   

          });
// ]]></script>

Try it »


User Ans/Comments

📖 Read More


Advertisements