jQuery :first-of-typeSelector
Examples
Select every <p> element that is the first <p> element of its parent:
$("p:first-of-type")
Try it Yourself »
Definition and Usage
The :first-of-type selector selects all elements that are the first child of a specific type of their parent.
Tip:This selector is the same as :nth-of-type(1).
Tip:Please use:last-of-typeselector to select all elements that are the last child of a specific type of their parent.
Syntax
$(":first-of-type")
Try it Yourself - Examples
Select the first <p> element of every <div> element
How to select the first <p> element of every <div> element.
The difference between :first, :first-child, and :first-of-type
Demonstrate the difference between the :first, :first-child, and :first-of-type selectors.
Other Extensions
jQuery Selectors