jQuery is()Method
Example
If the parent element of <p> is a <div> element, display an alert message:
if ($("p").parent().is("div")) {
alert("The parent element of p is div");
}
alert("The parent element of p is div");
}
Try it Yourself »
Definition and Usage
The is() method checks whether a selected element matches a selector.
Syntax
$(selector).is(selectorElement,function(index,element))
| Parameter | Description |
|---|---|
| selectorElement | Required. A selector expression used to check the matched element set against the selector/element/jQuery object. If there is at least one matching element, return true; otherwise, return false. |
| function(index,element) |
Optional. Specifies a function to execute for the selected set of elements.
|
Other Extensions
jQuery Traversal Methods