Dominofoe Dominofoe - 1 month ago 7x
jQuery Question

Target the first child of all instances of a class using jquery

I have 2 buttons inside of a div.

<div class="pull-left address-selector">
<a class="btn btn-primary btn-sm"><i class="fa fa-envelope"></i></a>
<a class="btn btn-primary btn-sm"><i class="fa fa-wrench"></i></a>

The class
is found in many places on the page.
How do i select the first child of all the instances of

$(".address-selector a:first").hide();
This just works on the first found instance of


Use :first-child

While :first matches only a single element, the :first-child selector can match more than one: one for each parent. This is equivalent to :nth-child(1).

In this case:

$(".address-selector a:first-child").hide();