Wiki

Clone wiki

LiteQuery / index

index()

#!javascript
index()

Description

Get the index of the element within the element's parent's children. If there are multiple elements selected, the index of the first element in the selection is returned.

Example

Initial Markup:

#!html
<body>
    <ul>
        <li id='MyId'></li>
        <li id='MyOtherId'></li>
        <li id='AndAnotherId'></li>
    </ul>
</body>
Executing
#!javascript
console.log('index: ' + lq('#AndAnotherId').index());  // index: 2
back to API

Updated