.first()


.first()Возвращает: jQuery

Описание: Возвращает первый элемент из всех выбранных. Эквивалентно .eq(0).

  • Добавлен в версии: 1.4.first()

    • This method does not accept any arguments.

Given a jQuery object that represents a set of DOM elements, the .first() method constructs a new jQuery object from the first element in that set.

Consider a page with a simple list on it:

1
2
3
4
5
6
7
<ul>
<li>list item 1</li>
<li>list item 2</li>
<li>list item 3</li>
<li>list item 4</li>
<li>list item 5</li>
</ul>

We can apply this method to the set of list items:

1
$( "li" ).first().css( "background-color", "red" );

The result of this call is a red background for the first item.

Примеры использования