Detects a collection of matching elements based on a selector, DOM element, or JQuery object, and returns true if at least one of the elements conforms to the given expression.
Returns ' false ' if no element is met, or if the expression is not valid. "Note:" in jquery 1.3, all expressions are supported. In previous releases, a complex expression, such as a hierarchy selector (such as +, ~ and >), would always return true
Instance:
<! DOCTYPE html> $(function(){ /*This function returns a Boolean value, and now we know that a filter that can return a Boolean value has two Hasclass (Class) | is (expr | jqobj | ele | function); */ $(' Li '). Click (function(index) {varBOOL = $ ( This). Is (function(index) {return$ (' strong ', This). Size () = = 2; }); if(BOOL) {$ ( This). css ({' Background ': ' Red ', ' color ': ' #000 ', ' cursor ': ' pointer '),}); }Else{ $( This). css ({' Background ': ' Green ', ' color ': ' #FFF ', ' cursor ': ' pointer '),}); } }); });</script>
[jquery filter is (expr | jqobj | ele | function)] This method is used to detect a collection of matching elements based on selectors, Dom elements, or jquery objects, if any, on top of the selector, and returns true if any