Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

jQuery first() method

jQuery first() method

jQuery Traversal Methods jQuery Traversal Methods

Example

Select the first

the first inside the element

element:

$("div p").first()

Try it »


Definition and Usage

The first() method returns the first element of the selected elements.

**Tip:** To return the last element, use last() method.


Syntax

$(

selector

).first()


More examples

Select

the first in the collection of elements Element
How to select

the first in the collection of elements .


jQuery Traversal Methods jQuery Traversal Methods