I have something close to this:
<div class="batman-pictures">
<a><img /></a>
<a><img /></a>
<a><img /></a>
<a><img /></a>
<a><img /></a>
<a><img /></a>
</div>
I don't know how many <a><img /></a> that will be generated (I am fetching them from an API), and I want to delete all elements after the first three(n) <a><img /></a>. How can I do this in jQuery?
Try this.
$(".batman-pictures a:nth-child(3)").nextAll().remove();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With