Latest web development tutorials

jQuery first () method

jQuery traversal methods jQuery traversal methods

Examples

Select the first <div> element within the first <p> element:

$("div p").first()

try it"

Definition and Usage

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

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


grammar

$(selector).first()


Examples

More examples

Select <p> The first element in the set a <span> element
How to choose <p> The first element in the set <span> element.


jQuery traversal methods jQuery traversal methods