gpt4 book ai didi

jquery - 删除元素和元素之前的内容

转载 作者:行者123 更新时间:2023-12-01 00:50:33 25 4
gpt4 key购买 nike

我正在尝试删除元素和内容当用户单击按钮时,位于 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com