Selector.nth Method

Returns elements with the specified index. The index starts at 0. Negative index values indicate the element’s location relative to the final element of the array.

Selector().nth(index) → Selector
Argument Type Description
index Number Zero-based index.

Examples

// Selects the third input element.
const secondInput = Selector('input').nth(2);

// Selects the last div element.
const lastDiv = Selector('div').nth(-1);