gpt4 book ai didi

jquery - 如何使用Jquery删除html标签?

转载 作者:行者123 更新时间:2023-12-01 07:01:04 24 4
gpt4 key购买 nike

我们如何使用 Jquery 删除 html 标签,例如我们有这个 html

<div><dd>hello world</dd></div>

我想删除<dd>标记并生成此输出

<div>hello world</div>

最佳答案

您可以使用.replaceWith() ,例如:

$("dd").replaceWith(function() { return $(this).contents(); });

You can test it out here .

关于jquery - 如何使用Jquery删除html标签?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3933866/

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