从下面的
HTML我想删除div和H2标签,但使用
jquery保留UL标签.
@H_404_2@请告诉我如何实现这一点
<div class="row"> <h2><asp:Literal ID="categoryTitle" runat="server"></asp:Literal></h2> <ul class="tree js-catTree" id="treeContainer" runat="server"></ul> </div>@H_404_2@谢谢
解决方法
你可以使用
replaceWith()
$('.row').replaceWith(function() { return $('ul',this); });@H_404_2@Working Demo