Easy Tutorial
❮ Misc Grep Jquery Traversing ❯

jQuery is() Method

jQuery Traversal Methods

Example

If the parent of <p> is a <div> element, display an alert message:

if ($("p").parent().is("div")) { alert("The parent of p is div"); }

Definition and Usage

The is() method is used to check if the selected element matches the selector.


Syntax

Parameter Description
selectorElement Required. A selector expression, checks the set of matched elements against the selector/element/jQuery object. Returns true if at least one of the elements matches, otherwise returns false.
function(index, element) Optional. Specifies a function to run for the group of selected elements. index - The index position of the element. element - The current element ("this" selector can also be used).

jQuery Traversal Methods

❮ Misc Grep Jquery Traversing ❯