最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to remove all tags after certain tag? - Stack Overflow

programmeradmin1浏览0评论

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();
发布评论

评论列表(0)

  1. 暂无评论