The is() method is used to check if one of the selected elements matches the selectorElement.
$(selector).is(selectorElement, function(index, element))
Parameters: This method accepts parameters above mentioned and below described:-
- selector: It is an optional parameter. It specifies the selector from which event will remove.
- selectorElement: It is a required parameter which specifies a selector expression, element or a jQuery object to match the current set of elements against. It returns true if there is at least one match from the given argument, and false if not.
- function(index, element): It is an optional parameter which specifies a function to run for the group of selected elements.
- index: the index position of the element
- element: the current element (the “this” selector can also be used)
Below example illustrate the is() method in jQuery:
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.