<div class="test mypro demo-class" id="test-1">test</div>
<div class="test mypro demo-class" id="test-3">test</div>
<div class="test mypro demo-class" id="test-4">test 2 no demo class</div>
<div class="test mypro" id="test-2">test 2 no demo class</div>
在上面的代码中我想删除id为#test-2的div,另外条件检查div不应该有.demo-class 我试过这个
$("#test-2 div:not(.demo-class)").remove();
请帮忙 提前谢谢
答案 0 :(得分:1)
答案 1 :(得分:0)
目前,您有两个元素id
test-2 ,将其分类到类:
<div class="test mypro demo-class test-2">test 2 no demo class</div>
<div class="test mypro test-2">test 2 no demo class</div>
然后使用:
$(".test-2:not(.demo-class)").remove()