jQuery is() method
Example
If both the
the parent element of the, is
element, pop up an alert message:
index - the index position of the element
element - the current element (the "this" selector can also be used)
|
if ($("p").parent().is("div")) {
alert("the parent of p is div");
}
Try it »
Definition and usage
The is() method is used to check whether the selected element matches a selector.
Syntax
$(
selector
).is(
selectorElement,
function
(index
,
element)
)
| Parameters | Description |
|---|---|
| selectorElement | Required. A selector expression that checks the set of matched elements against the selector/element/jQuery object; returns true if at least one matching element exists, otherwise returns false |
| function(index,element) |
Optional. Specifies a function to execute on the group of selected elements. |
jQuery Traversal Methods