Latest web development tutorials

jQuery: first-of-type selector

jQuery selector jQuery selector

Examples

Each <p> element of its parent element belonging to select the first <p> element:

$("p:first-of-type")

try it"

Definition and Usage

: All elements of first-of-type selector to select a specific type of the first child element of its parent element.

Note: The selector with: nth-of-type (1 ) the same.

Tip: Use : last-of-type selector to select all of the elements belonging to the last child element of its parent element of a particular type.


grammar

$(":first-of-type")


Examples

Try - Example

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

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


jQuery selector jQuery selector