Reputation: 603
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>
</div>
The class .address-selector
is found in many places on the page.
How do i select the first child of all the instances of .address-selector
?
$(".address-selector a:first").hide();
This just works on the first found instance of .address-selector
Upvotes: 0
Views: 27
Reputation: 28611
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();
Upvotes: 2