jQuery has Method Example


jQuery “has() Method ” is used to select all elements which have descendants that matches the selector element.


Syntax : jQuery has() method

$(selector).has(element);

element : Required , is used to match the elements against.

jQuery has Method Example

jQuery has() Method Example with syntax

<script type="text/javascript">
         $(document).ready(function(){ 
              $( "#sliceExample" ).on( "click", function(event) {             
                 $("div").has("span").css("background","yellow");
              });
               
          });
</script>

Try it »


Advertisements

Add Comment

📖 Read More