大家好,我有一个需要修改的 html..这是我的 html
<div class="navbar navbar-inverse">
<div class="navbar-inner">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse"><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span></a>
<div class="nav-collapse collapse">
<ul class="nav-pills SC-Topmenu nav">
<div class="top-nav ">
<div class="title-bar">
<div data-original-title="Doubleclick for edit" class="title username editable editable-click" data-type="text" data-pk="" data-url="/post" rel="tooltip" data-placement="bottom">Home</div>
</div>
<div class="panel"></div>
</div>
<div style="display: inline-block;" class="top-nav">
<div class="title-bar">
<div style="display: block;" data-original-title="Doubleclick for edit" class="title username editable editable-click editable-unsaved" data-type="text" data-pk="" data-url="/post" rel="tooltip" data-placement="bottom">Categorys</div>
</div>
<div class="panel"></div>
<div style="display: table-cell;" class="jstree jstree-8 jstree-2">
<ul>
<li id="Li7" class="Root jstree-last jstree-open"><ins class="jstree-icon"> </ins><a href="javascript:void(0)" class="Titleanchor"><ins class="jstree-icon"> </ins>Title1</a>
<ul class="MenuContentholder">
<li><a><ins class="jstree-icon"> </ins>1</a></li>
<li><a><ins class="jstree-icon"> </ins>2</a></li>
</ul>
</li>
</ul>
</div>
<div style="display: table-cell;" class="jstree jstree-10 jstree-focused jstree-4">
<ul>
<li id="Li6" class="Root jstree-last jstree-open"><ins class="jstree-icon"> </ins><a href="javascript:void(0)" class="Titleanchor"><ins class="jstree-icon"> </ins>Title2</a>
<ul class="MenuContentholder">
<li><a><ins class="jstree-icon"> </ins>1</a></li>
<li><a><ins class="jstree-icon"> </ins>2</a></li>
</ul>
</li>
</ul>
</div>
<div style="display: table-cell;" class="jstree jstree-7 jstree-1">
<ul>
<li id="Li5" class="Root jstree-last jstree-open"><ins class="jstree-icon"> </ins><a href="javascript:void(0)" class="Titleanchor"><ins class="jstree-icon"> </ins>Title3</a>
<ul class="MenuContentholder">
<li><a><ins class="jstree-icon"> </ins>1</a></li>
<li><a><ins class="jstree-icon"> </ins>2</a></li>
</ul>
</li>
</ul>
</div>
<div style="display: table-cell;" class="jstree jstree-9 jstree-3">
<ul>
<li id="Li4" class="Root jstree-last jstree-open"><ins class="jstree-icon"> </ins><a href="javascript:void(0)" class="Titleanchor"><ins class="jstree-icon"> </ins>Title4</a>
<ul class="MenuContentholder">
<li><a><ins class="jstree-icon"> </ins>1</a></li>
<li><a><ins class="jstree-icon"> </ins>2</a></li>
</ul>
</li>
</ul>
</div>
</div>
</ul>
</div>
</div>
上面的html应该这样转换
<div class="navbar navbar-inverse">
<div class="navbar-inner">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse"><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span></a>
<div class="nav-collapse collapse">
<ul class="nav-pills SC-Topmenu nav">
<li><a href="Index.html">Home </a></li>
<li><a href="Index.html">Categorys </a>
<div>
<ul>
<h3>Title1</h3>
<li><a>1</a></li>
<li><a>2</a></li>
</ul>
<ul>
<h3>Title2</h3>
<li><a>1</a></li>
<li><a>2</a></li>
</ul>
<ul>
<h3>Title3</h3>
<li><a>1</a></li>
<li><a>2</a></li>
</ul>
<ul>
<h3>Title4</h3>
<li><a>1</a></li>
<li><a>2</a></li>
</ul>
<ul>
<h3>Title5</h3>
<li><a>1</a></li>
<li><a>2</a></li>
</ul>
</div>
</li>
</ul>
</div>
</div>
</div>
到目前为止,所有属性都应该被删除
$('.top-nav').each(function () {
var container = $(this);
//$(container).find('.custom-content').each(function () { var custom_content = $('.custom-content').html(); $(container).find('.MenuContentholder').append('<li><a href="javascript:void(0)">' + custom_content + '</a></li>'); });
$(container).find('.jstree-icon').addClass('icon');
$(container).wrap('<div></div>')
$(container).wrap('<li></li>');
$(container).find('.title').wrap('<a href="#" class="SC-Title"><a>');
//$(container).find('.widget-controls').remove();
$(container).find('.SC-Title').html($(container).find('.SC-Title').children().html());
$(container).find('.Root').parent('ul').unwrap();
$(container).find('.SC-Title').unwrap();
//$(container).find('ul').parent('div').children('ul').unwrap();
//$('.panel').remove();
alert($('.' + Areaclassselector).html());
$('.Titleanchor').each(function () {
$(this).html('<h3>' + $(this).html() + '</h3>');
$(this).find('h3').unwrap();
});
$(container).find('ins').remove();
});