jQuery: .eq()

The .eq() method reduces the set of matched elements to the one at the specified index.

The supplied index identifies the position of this element in the set.

<!doctype html>
<html>
<head>
    <title>eq demo</title>
    <script src='//code.jquery.com/jquery-1.10.2.js'></script>
    <style>
        div {
            width: 60px;
            height: 60px;
            margin: 10px;
            float: left;
            border: 2px solid blue;
        }

        .blue {
            background: blue;
        }
    </style>
</head>
<body>

<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>

<script>
    $('body').find('div').eq(2).addClass('blue');
</script>

</body>
</html>

Try The Code

In the example above, the supplied index is 2.

Series Navigation<< jQuery: Other common traversing methods
jQuery: .filter() >>