im working on a very simple "Multilevel menu" with jQuery.
The links inside the .sub-nav
can't be clicked because the parent li
is above them. ¿Any help?
Thanks!!
Bind click event to link inside <li>
element, when clicked get parent of this link element and then slide toggle sub-nav.
Give it a try. ;)
EDIT:
I made it with a next() jQuery selector: here's js code:
$(document).ready(function(){
$('.nav > li > a').click(function(e) {
e.preventDefault();
$(this).next().slideToggle();
});
});
Notice that >
prevents the clicked <li>
element itself from sliding. It basically says that I want to bind event of clicking link which is direct child of <li>
element which is direct child of an element with .nav
class.