How to remove the empty link in menu in the wordpress using jquery?

Here is the html code for menu in wordpress, when i responsive the my theme

Html Code for menu is :

Read More
<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>

the empty have not contain the sublink which customize in the wordpress menu settings home, pricing, Apps are the main menu and the Financials is the submenu of apps and “expenses and more ”
is the sublink of the Financials menu , Now i need to remove the empty sublink in the main and sub menu how can we do in jquery?

Related posts

Leave a Reply

1 comment

  1. The answer for this is

    $(document).ready(function(){
         $("#menu-headermenu li span a.sub_link").each(function(){    
           var emty=$(this).text();      
           if(emty.length==0){          
               $(this).remove();           
           }
         })
     })