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

jQuery :first-of-type Selector

jQuery :first-of-type Selector

jQuery selector jQuery selector

Example

Select the first

element of every

element:

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

Try it »


Definition and Usage

The :first-of-type selector selects all elements that are the first child of their specific type within their parent.

**Tip:** This selector is the same as :nth-of-type(1).

**Tip:** Please use :last-of-type selector to select all elements that are the last child of their specific type within their parent.


Syntax

$(":first-of-type")


Try it - Example

Select all

first element in the

Element
How to select all

first element in the

.

The difference between :first, :first-child and :first-of-type
Demonstrates the difference between the :first, :first-child and :first-of-type selectors.


jQuery selector jQuery selector