コンテナ内の要素のリストがあります。要素は、タグを含むliです。
私の問題は、すべてのaがliタグ内にあるわけではないことです(これは以前のjquery操作によるものです)。
リストを繰り返し処理して、liに含まれていないタグをリスト内に配置するにはどうすればよいですか?
関連するhtmlは次のとおりです。
<ul class="dropdownmenu" style="display: none; ">
<li><a href="Advanced">Advanced</a></li>
<li><a href="Account">Account</a></li>
<a href="Credit Notes">Credit Notes</a>
<a href="Invoices In">Invoices In</a>
<li><a href="Invoices Out">Invoices Out</a></li>
<li><a href="Invoices Jobs">Invoices Jobs</a></li>
</ul>
そして私のJavaScript:
$('li[id^="nav"]').each(function(){ // For each nav item that has fallen out of the menu due to low res etc...
pos = $(this).position() ;
if(pos.top > 0)
{
var cnt = $('ul.dropdownmenu', this).contents()
$('ul.dropdownmenu', this).replaceWith(cnt);
$('span.droptop', this).remove();
$('a:has(i span)', this).remove() ;
$('i', this).remove() ;
// NOW WRAP As in LIs THAT DON'T HAVE ONE
movables += $(this).html() ;
$(this).hide() ;
somethingHidden = true ;
}
})