Reputation: 110093
I have the following items on the html page:
$(".pv-profile-section__card-action-bar").length
3
How would I click all of them instead of just the first one, which is done via:
$(".pv-profile-section__card-action-bar").click()
Upvotes: 0
Views: 46
Reputation: 370659
Use each
to iterate over every item, and then you can trigger a click
on each:
$(".pv-profile-section__card-action-bar").click(function() {
console.log(this.textContent);
});
$(".pv-profile-section__card-action-bar").each(function() {
$(this).click();
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="pv-profile-section__card-action-bar">foo</div>
<div class="pv-profile-section__card-action-bar">bar</div>
Upvotes: 3