Easy Tutorial
❮ Html Val Jq Sel Root ❯

jQuery Miscellaneous index() Method

jQuery Miscellaneous Methods

Example

Get the index of the clicked <li> element relative to its siblings:


Definition and Usage

The index() method returns the index position of a specified element relative to other specified elements.

These elements can be specified by a jQuery selector or DOM elements.

Note: If the element is not found, index() will return -1.


Index of the First Matched Element Relative to Siblings

Get the index position of the first matched element relative to its siblings.

Syntax


Index of an Element Relative to a Selector

Get the index position of an element relative to a selector.

The element can be specified by a DOM element or jQuery selector.

Syntax

Parameter Description
element Optional. Specifies the element to get the index position of. Can be a DOM element or jQuery selector.

jQuery Miscellaneous Methods

❮ Html Val Jq Sel Root ❯