Latest web development tutorials

jQuery: first-child selector

jQuery selector jQuery selector

Examples

Select elements belonging to his father and brothers and all the elements for the first <p> element:

$("p:first-child")

try it"

Definition and Usage

: First-child selector to select the first part of its parent element and all sibling elements.

Tip: Use : last-child selector to select elements that belong to the last child element of its parent element.


grammar

$ ( ": First-child")


Examples

Try - Example

Select all <div> elements in the first <p> element
How to select all <div> elements in the first <p> element.

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

: first,: first-child and: first-of-type between different
Demo: first,: first-child and: first-of-type selector between different.


jQuery selector jQuery selector