I have this HTML:
<li>
<input type="radio" class="checkbox" name="myName" id="Id001"/>
One
<img class="resetRadio" src="star.png"/>
</li>
<li>
<input type="radio" class="checkbox" name="myName" id="Id002"/>
Two
<img class="resetRadio" src="star.png"/>
</li>
<li>
<input type="radio" class="checkbox" name="myName" id="Id003"/>
Three
<img class="resetRadio" src="star.png"/>
</li>
And I want to remove the img of all li elements except the first one.
In the HTML document there are a lot of other li, input, and img elements.
The only thing I have is the name of the input (myName).
I tried:
var radios = $(':radio[name="myName"]');
radios.parent().remove(".resetRadio");
To remove all imgbut it doesn’t work (first I want to remove all, then all except the first)
Your code would remove parents of radiobuttons with class
resetRadio– whitch you don’t have. You want to remove children of said parents – with the classresetRadio.refine your second line to reflect this logic:
to remove all but first change first line to: