Home >>jQuery Tutorial >jQuery :first Selector

jQuery :first Selector

jQuery :first Selector

jQuery :first selector in jQuery is used to selects one single element. To select more than one element (one for each parent) you can use the :first-child selector.

Here is an Example of jQuery :first Selector:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
$("p:first").css("background-color", "orange");
<p>This is the first paragraph.</p>
<p>This is the second paragraph.</p>
<p>This is the Third paragraph.</p>


This is the first paragraph.

This is the second paragraph.

This is the Third paragraph.