jQuery is() Method

The is() method in jQuery is used to check whether one of the selected elements matches the value in parameter selectorEle.


The syntax is as follows −


Above, selectorEle is a selector expression, element or jQuery object to match with the current set of the element. The func parameter is used to specify a function to run for the group of selected elements.


Let us now see an example to implement the jQuery is() method −

 Live Demo

<!DOCTYPE html>
div {
.demo * {
   display: block;
   border: 2px solid yellow;
   color: blue;
   padding: 10px;
   margin: 10px;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
         if ($("span").parent().is("li")) {
            alert("Yes, li is a parent of span");
<body class="demo">great-great-grandparent


This will produce the following output −

Click the “Check” button. On clicking, an alert box will be visible −