I need to remove tags going after #first
and only in #container
.
How can I do it with jQuery?
<div id="container">
<div id="first"></div>
<div id="remove_me_1"></div>
<div id="remove_me_2"></div>
<div id="remove_me_3"></div>
<a href="" id="remove_me_too">Remove me too</a>
</div>
Thank you
I need to remove tags going after #first
and only in #container
.
How can I do it with jQuery?
<div id="container">
<div id="first"></div>
<div id="remove_me_1"></div>
<div id="remove_me_2"></div>
<div id="remove_me_3"></div>
<a href="" id="remove_me_too">Remove me too</a>
</div>
Thank you
Share Improve this question asked May 12, 2010 at 10:19 KirzillaKirzilla 16.6k27 gold badges89 silver badges131 bronze badges3 Answers
Reset to default 11You can use nextAll
method: http://api.jquery./nextAll/
$("#first").nextAll().remove();
$.("#container #first ~ *").remove();
$("#container :gt(0)").remove();