[英]Remove <div> using jQuery
I have this HTML code: 我有这个HTML代码:
<div id="note_list">
<div class="note">
Text 1
<a href="">X</a>
</div>
<div class="note">
Text 2
<a href="">X</a>
</div>
<div class="note">
Text 3
<a href="">X</a>
</div>
<div class="note">
Text 4
<a href="">X</a>
</div>
<div class="note">
Text 5
<a href="">X</a>
</div>
</div>
Now I would like to use jQuery to delete a <div>
element AFTER the 'X' clicking, is it possible? 现在我想使用jQuery在'X'点击后删除
<div>
元素,是否可能?
First X closes: 第一个X关闭:
<div class="note">
Text 1
<a href="">X</a>
</div>
etc etc. Can I remove a div without using id=""
? 等等。我可以在不使用
id=""
情况下删除div吗?
Thank you! 谢谢!
$(".note a").click(function(e) {
e.preventDefault();
$(this).parent().remove();
});
or instead of remove()
you could use slideUp()
或者代替
remove()
你可以使用slideUp()
$(".note a").click(function() {
$(this).parent().remove();
});
u can check here http://jsfiddle.net/3JCR7/1/ 你可以在这里查看http://jsfiddle.net/3JCR7/1/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.