In my HTML are two divs with identical classes. If I want to remove the div by class, both of them get removed. How can I (whilst using Jquery) remove the second div by class? Is there a way for it to 'skip' the first div it finds?
The code looks like this:
<div class="wrapper">
<div class="randomdiv">
<div class="oneofthetwodivs">
</div>
</div>
<div class="randomdiv"></div>
<div class="randomdiv"></div>
<div class="oneofthetwodivs">
</div>
You could use eq()
to target the second element with that class (it is zero based):
$('.oneofthetwodivs').eq(1).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