jQuery is method
jQuery “is()” method is used to match the current set of elements against the jQuery selector,jQuery Object or jQuery element. If argument matches any of these elements it returns true .
Syntax : jQuery is() method
$(selector).is(selector-element,function(index,element));
selector-element: Pattern to match the current set of elements against selector-element.
– index : Current index of element.
– element : Current element.
jQuery is() Example
jQuery is Method – Example
<script type="text/javascript"> $(document).ready(function(){ $( "ul" ).on( "click", function(event) { var target = $(event.target); if(target.is("li")){ $(target).css("border","4px solid red"); } if(target.is("span")){ $(target).css("background","yellow"); } }); }); </script> |
Advertisements