删除父元素,但在HTML中使用jquery保留子元素 [英] remove parent element but keep the child element using jquery in HTML
本文介绍了删除父元素,但在HTML中使用jquery保留子元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想从下面的HTML中删除div和H2标签,但使用jquery保留UL标签.
From the below HTML i want to remove the div and H2 tags but keep the UL tag using jquery.
请告知我该如何实现
<div class="row">
<h2><asp:Literal ID="categoryTitle" runat="server"></asp:Literal></h2>
<ul class="tree js-catTree" id="treeContainer" runat="server"></ul>
</div>
谢谢
推荐答案
您可以使用 replaceWith()
You can use replaceWith()
$('.row').replaceWith(function() {
return $('ul', this);
});
这篇关于删除父元素,但在HTML中使用jquery保留子元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文