Last active
August 26, 2020 14:12
-
-
Save munts/04deefaed8c503e7ed423ec89879f81c to your computer and use it in GitHub Desktop.
prevent parent item from being clickable if it has children items
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$("ul.menu li:has(ul.nav-drop)").hover(function () { | |
$(this).children("a").click(function () { | |
return false; | |
}); | |
}); | |
<ul class="menu"> | |
<li class="menu-item menu-item--current"> | |
<a class="menu-link" href="http://sitzmark.local/about-us/">About Us</a> | |
<ul class="nav-drop"> | |
<li class="nav-drop-item"> | |
<a href="http://sitzmark.local/winter-amenities/">Winter Amenities</a> | |
</li> | |
<li class="nav-drop-item"> | |
<a href="http://sitzmark.local/concierge/">Concierge</a> | |
</li> | |
</ul> | |
</li> | |
<li class="menu-item "> | |
<a class="menu-link" href="http://sitzmark.local/accommodations/">Accommodations</a> | |
</li> | |
<li class="menu-item "> | |
<a class="menu-link" href="http://sitzmark.local/rates/">Rates</a> | |
</li> | |
<li class="menu-item "> | |
<a class="menu-link" href="http://sitzmark.local/book-now/">Book Now</a> | |
</li> | |
</ul> |
btw, I got this solution from Chris Coyier's article here: https://css-tricks.com/snippets/jquery/disable-parent-links-in-nested-list-navigation/
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The goal is to prevent 'About Us' from being clickable and only the 'nav-drop-item' being clickable.