2

这是wordpress中菜单的html代码,当我响应我的主题时

菜单的 HTML 代码是:

<ul class="menu l_tinynav1" id="menu-headermenu">
<li class="menu-item menu-item-type-post_type menu-item-object-page current-menu-item page_item page-item-20 current_page_item" id="menu-item-7365">
<span class="parent-nav-menu-span">
<a class="head_link" href="/">Home</a>
<a class="sub_link" href="/"></a>
</span></li>
<li class="menu-item menu-item-type-custom menu-item-object-custom" id="menu-item-19">
<span class="parent-nav-menu-span"><a class="head_link" href="/pricing/">Pricing</a><a class="sub_link" href="/pricing/"></a></span></li>
<li class="spanarrow spanremove menu-item menu-item-type-custom menu-item-object-custom" id="menu-item-12">
<span class="parent-nav-menu-span"><a class="head_link" href="/financials" title=" Applications">Apps</a><a class="sub_link" href="/financials" title="Applications"></a></span>
<ul class="sub-menu sub-arrow2 access1024">
<li class="arr menu-item menu-item-type-post_type menu-item-object-page firstlist" id="menu-item-7370"><div class="top_arrow"> </div>
<span class="not-sub-nav-menu-span"><a class="head_link" href="/financials/" title="Software">Financials</a><a class="sub_link" href="/financials/" title=" Software"> expenses and more</a></span>
</li>
</ul>
</li>
</ul>

空的没有包含在wordpress菜单设置中自定义的子链接,定价,应用程序是主菜单,财务是应用程序的子菜单,“费用和更多”是财务菜单的子链接,现在我需要删除主菜单和子菜单中的空子链接我们如何在jquery中做?

4

1 回答 1

3

答案是

$(document).ready(function(){
     $("#menu-headermenu li span a.sub_link").each(function(){    
       var emty=$(this).text();      
       if(emty.length==0){          
           $(this).remove();           
       }
     })
 })
于 2013-01-07T14:02:13.147 回答