I need to remove tags going after #first
and only in #container
. How can I do it with jQuery?
我需要删除#first的标签,并且只在#container中。我怎么用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
谢谢你!
3 个解决方案
#1
11
You can use nextAll
method: http://api.jquery.com/nextAll/
可以使用nextAll方法:http://api.jquery.com/nextAll/
$("#first").nextAll().remove();
#2
1
$.("#container #first ~ *").remove();
#3
1
$("#container :gt(0)").remove();
#1
11
You can use nextAll
method: http://api.jquery.com/nextAll/
可以使用nextAll方法:http://api.jquery.com/nextAll/
$("#first").nextAll().remove();
#2
1
$.("#container #first ~ *").remove();
#3
1
$("#container :gt(0)").remove();