jQuery Tutorial Tutorials - jQuery .eq() method

jQuery .eq() method

The .eq(N) method in jQuery is used to the get the Nth matched element.

jQuery .eq() method Syntax

.eq(index)

index is an interger indicating the 0-based position of the element. If the index is negative,counting backwards from the last element.

jQuery .eq() method Example

example

Highlight the item 3 and the second item counting from backwards.

$('li').eq(2).css('background','cyan');
$('li').eq(-2).css('background','cyan');

Try now

Date:2019-08-26 13:27:49 From:www.Lautturi.com author:Lautturi