我正在尝试删除元素和内容 当用户单击按钮时,位于 div 内的链接之前。 最好的方法是什么??
<div id="dialog" class="window">
//will be inserted a <select> element and few text here
//but I want to clear them after the user click a button
<a href="#" class="close">Close it</a> // I want to keep this <a> link.
</div>
我的 Jquery
$('.model').click(function(e) {
$("#dialog").empty(); //I can't use this because <a> will be deleted. Any better ideas?
});
感谢您的回复...
最佳答案
只需将所有这些元素包装在 div 中并删除它们
$('#select-wrapper').remove();
或者做得更友好一点
$('#select-wrapper').fadeOut(500, function() { $(this).remove(); });
关于jquery - 删除元素和元素之前的内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2946615/