gpt4 book ai didi

javascript - 与 jQuery 中的 append 相反

转载 作者:IT王子 更新时间:2023-10-29 02:48:51 24 4
gpt4 key购买 nike

我使用 .append添加到 div

$(this).append('<ul><li>test</li></ul>');

如何搜索 <ul>如果它存在于 $(this) 的子项中,则将其删除?

最佳答案

您可以使用remove()。有关 jQuery remove() 的更多信息.

$(this).children("ul").remove();

请注意,这将删除 所有 ul 子元素。

关于javascript - 与 jQuery 中的 append 相反,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4934488/

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