我们如何使用Jquery删除html标签? [英] How can we remove html tag by using Jquery?
本文介绍了我们如何使用Jquery删除html标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们如何使用Jquery删除html标签,例如,我们有这个html
How can we remove html tag by using Jquery e.g we have this html
<div><dd>hello world</dd></div>
我要删除<dd>
标签并生成此输出
i want to remove <dd>
tag and produce this output
<div>hello world</div>
推荐答案
您可以使用 .replaceWith()
,例如:
You can use .replaceWith()
, for example:
$("dd").replaceWith(function() { return $(this).contents(); });
这篇关于我们如何使用Jquery删除html标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文