Latest web development tutorials

jQuery: first selector

jQuery selector jQuery selector

Examples

Select the first <p> element:

$("p:first")

try it"

Definition and Usage

: First selector to select the first element.

Note: This option is only used to select a single element. Use : first-child selector to select multiple elements (each element of a parent).

The most common usage: used in conjunction with other selectors, select specific combinations of the first element (like the example above).

Tip: To select specific combinations of the last elements, use : last selector.


grammar

$(":first")


Examples

Try - Example

: between different first-child: first and
Demo: different first-child choose between: first and.


jQuery selector jQuery selector