A jQuery selector is broad and selects all elements on the page based on your query. The need may rise when you need to select a single item, based on its position, but there isn’t an easy way to select that item without editing the code.
After you make your selection with jQuery, you can chain the
.eq() method and pass in the index of the selection you want to work
The selection index is zero-based, so the first item in the
selection would be
where 0 represents the first item in the selection.
$().eq(4); represents the fifth
Let’s use the end of the season standings for the National Hockey League (NHL) conferences as an example of how we can show which teams made the playoffs and which didn’t. What we need to do is list all the teams in each conference in the order they finished the season in. Since the top eight teams in each conference make it to the playoff round, we just need to figure out the eighth entry in each list and draw a line: