Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个菜单,与大多数菜单一样,当当前页面与所选菜单项匹配时,它会将“current-menu-item”添加到列表项的类中。但是,我想从当前菜单项中删除链接。我正在使用以下代码,但没有任何乐趣。谁能指出出了什么问题:
jQuery(document).ready(function(){ jQuery(".current-menu-item li:has(a[href=''])").remove(); });
尝试这个
jQuery('.current-menu-item li a').removeAttr( 'href' );