我想做自定义导航助行器
如果有任何子菜单,则从列表项中删除标记,例如在gallery gallery
下面我试图留下空链接。但它不起作用。 ' a href ="#">完全必须从画廊项目中删除
我至少分享了10个论坛和小组。我找不到解决方案 我真的很感激你的回答
<ul id="menu-mainmenu" class="top-menu"><li class=" normal-menu"><a href="http://www.event282.com/"><span>HOME</span></a></li>
<li class=" menu-item-has-children "><span class="title"><a href="http://www.event282.com/?page_id=65"><span>GALERRIES</span></span></i>
<ul class="sub-menu">
<li><a href="http://www.event282.com/?galeri_kategorisi=hamilelik-fotograflari"><span>GALLERY1</span></a></li>
<li><a href="http://www.event282.com/?galeri_kategorisi=dugun-fotograflari"><span>GALLERY2</span></a></li>
<li><a href="http://www.event282.com/?galeri_kategorisi=dugun-cekimleri"><span>GALLERY3</span></a></li>
</ul></li>
<li class="normal-menu"><a href="http://www.event282.com/?page_id=60"><span>BIO</span></a></li>
<li class=" normal-menu"><a href="http://www.event282.com/?page_id=48"><span>CONTACT</span></a></li>
</ul>
答案 0 :(得分:0)
$(function() {
if($('li').hasClass(' menu-item-has-children ')) { $(this).find('span.title a').removeAttr("href"); }
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<ul id="menu-mainmenu" class="top-menu"><li class=" normal-menu"><a href="http://www.event282.com/"><span>HOME</span></a></li>
<li class=" menu-item-has-children "><span class="title"><a href="http://www.event282.com/?page_id=65"><span>GALERRIES</span></span></i>
<ul class="sub-menu">
<li><a href="http://www.event282.com/?galeri_kategorisi=hamilelik-fotograflari"><span>GALLERY1</span></a></li>
<li><a href="http://www.event282.com/?galeri_kategorisi=dugun-fotograflari"><span>GALLERY2</span></a></li>
<li><a href="http://www.event282.com/?galeri_kategorisi=dugun-cekimleri"><span>GALLERY3</span></a></li>
</ul></li>
<li class="normal-menu"><a href="http://www.event282.com/?page_id=60"><span>BIO</span></a></li>
<li class=" normal-menu"><a href="http://www.event282.com/?page_id=48"><span>CONTACT</span></a></li>
</ul>