yck*_*art 2 jquery selector jquery-selectors removechild
我尝试empty()一个div但排除一个特定的选择器.
什么我试过到目前为止:
$('.modal').find('.close').nextAll().empty();
$('.modal').find(':not(.close)').empty();
$('.modal').not('.close').empty();
$('.modal:not(.close)').empty();
Run Code Online (Sandbox Code Playgroud)
HTML:
<div class="modal">
<a href="#" class="close">Close</a>
...I've the need to be removed...
</div>
Run Code Online (Sandbox Code Playgroud)
可以这样做:
http://fiddle.jshell.net/KLh4E/11/
$(".modal").contents().filter(function(){
return !$(this).is('.close');
}).remove();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1694 次 |
| 最近记录: |