我正在尝试将现有的ul
移动到位于li
之前的现有ul
。
<ul class="sub-menu" aria-labelledby="desktop-submenu">
<li class="has-children current-page-ancestor current-page-parent">
<a href="/improve-clinical-care/clear/" class="current_page_item">Clear</a>
</li>
<ul class="sub-sub-menu">
<li class="level-three">
<a href="/improve-clinical-care/clear/clears-story/" class="current_page_item">Clear's Story</a>
</li>
<li class="level-three current-menu-item page-item-34 current_page_item">
<a href="/improve-clinical-care/clear/sign-up-for-clear/" class="current_page_item">Sign-Up for Clear<span class="sr-only">(current)</span></a>
</li>
</ul>
<li class="has-children critical-care">
<a href="/improve-clinical-care/critical-care/" class="current_page_item">Critical Care</a>
</li>
<ul class="sub-sub-menu">
<li class="level-three">
<a href="/improve-clinical-care/critical-care/pain-agitation-delirium/" class="current_page_item">Pain Agitation & Delirium</a>
</li>
<li class="level-three">
<a href="/improve-clinical-care/critical-care/glycemic-control/" class="current_page_item">Glycemic Control</a>
</li>
<li class="level-three">
<a href="/improve-clinical-care/critical-care/critical-care-working-group/" class="current_page_item">Critical Care Working Group</a>
</li>
</ul>
</ul>
我要做的是将<ul class="sub-sub-menu">
项移到前面的<li class="has-children">
,因为我们显然不能将ul
作为另一个ul
的孩子}}
这甚至可以用jQuery吗?我已经接近append()
方法了,但由于has-children
出现的次数很多,我最终得到了has-children
个LI中的一个sub-sub-menu
附在它上面。
对此的任何帮助都将非常感激。谢谢帮派!
答案 0 :(得分:0)
我已经解决了我自己的问题 - 呜呜!
$(".sub-sub-menu").each(function() {
$(this).prev(".has-children").append(this);
});
显然我已经非常接近了很多次,但却失去了prev
而不是siblings
或closest
。