admin管理员组

文章数量:1356104

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 badges
Add a ment  | 

3 Answers 3

Reset to default 11

You can use nextAll method: http://api.jquery./nextAll/

$("#first").nextAll().remove();
$.("#container #first ~ *").remove();
$("#container :gt(0)").remove();

本文标签: javascriptHow to remove all tags after certain tagStack Overflow