gpt4 book ai didi

javascript - 如何删除使用 jQuery 动态创建的类

转载 作者:行者123 更新时间:2023-12-02 18:47:43 25 4
gpt4 key购买 nike

$("#my").click(function() {
$(this.title).remove();
});

我使用 jQuery 动态添加和删除 html 内容,但如何删除动态添加的内容。

最佳答案

用于动态添加元素的事件委托(delegate)

试试这个

 $(document).on("click","#my",function(){
$(this).removeClass(this.title);
//or
$(this.title).remove();
});

关于javascript - 如何删除使用 jQuery 动态创建的类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16183912/

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