filter
UK[ˈfɪltə(r)] US[ˈfɪltɚ]
n. Filter; light filter; color filter; [化] filter
vi.Filter; penetrate; penetrate
vt.Filter; filter out
jquery filter() method syntax
Function: The filter() method reduces the set of matching elements to elements matching the specified selector.
Syntax: .filter(selector)
Parameters:
Parameter | Description |
selector | String value, containing the selector expression for matching the current set of elements. |
Description: If a jQuery object representing a collection of DOM elements is given, the .filter() method will construct a new one with a subset of matching elements. jQuery object. The selector used tests each element; all elements matching the selector are included in the result.
jquery filter() method example
<!DOCTYPE html> <html> <head> <style> div { width:60px; height:60px; margin:5px; float:left; border:2px white solid; } </style> <script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"></script> </head> <body> <div></div> <div class="middle"></div> <div class="middle"></div> <div class="middle"></div> <div class="middle"></div> <div></div> <script> $("div").css("background", "#c8ebcc") .filter(".middle") .css("border-color", "red"); </script> </body> </html>
Click the "Run instance" button to view the online instance