← Back to Index

.first()

Reduce the set of matched elements to the first in the set.

Examples

1. Get first element

// <li>A</li><li>B</li>
$('li').first().addClass('first-item');

Result

<li class="first-item">A</li>
<li>B</li>

Details

Equivalent to .eq(0).

Returns: A new SR object.