I have these elements :
<div class="container">
<div class="myTarget">a</div>
<div class="notMyTarget">b</div>
<div class="myTarget">c</div>
<div class="notMyTarget">d</div>
<div class="myTarget">e</div>
<div class="myTarget">f</div>
<div class="notMyTarget">g</div>
<div class="myTarget">h</div>
<div class="notMyTarget">i</div>
<div class="notMyTarget">j</div>
<div class="myTarget">k</div>
<div class="myTarget">l</div>
<div class="notMyTarget">m</div>
<div class="myTarget">n</div>
<div class="myTarget">o</div>
</div>
and I’d like to remove (for example) the 4° elements of the myTarget‘s collections div that are children of container. So in this case, I’d like to remove the one with f.
What’s the best and easy way to do it on jQuery? .index() can help?
Use the (zero-indexed)
:eq()selector:Counting up from 0, 3 represents the fourth
.myTargetelement.