- This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
Viewing 5 posts - 1 through 5 (of 5 total)
- The topic ‘Menu tweak’ is closed to new replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Home › Forums › JavaScript › Menu tweak
Currently, if I got a menu open and click the submenu it closes the menu. How do I prevent that? I want it to do nothing.
First of all, you’ve used invalid markup. Within an OL or a UL, the direct descendants have to be LI’s. A DIV can only be used if it’s within an LI.
To fix your issue, add this to your code:
$('.submenu').on('click', function(e){
e.stopPropagation();
});
This makes sure that clicking on a SUBmenu does not “bubble up” and triggers the click on the (parent) menu.
It worked. Thank you.
Well, it’s working like I want it to.
What could be the issues caused by using DIVs?
Should I change that? How?
If you want proper markup without breaking anything, this is how you could do it:
@shaneisme
Thank you very much. In the meantime a few things have changed but instead of “polluting” this thread I think I should probably open a new one.