I built a pretty normal submenu menu in a vertical column - nested UL, using slideToggle
to expand and collapse the submenu.
The problem I'm trying to solve is that the jump menu opens at the very end. (I am testing the latest version of Chrome.) This is probably most notable in the second “Benefits” submenu. It does not jump when the menu collapses, only when they expand.
I thought the problem might have something to do with :after
styles, added only when the menu is fully expanded. In particular, the current
class is added to the LI tag after the menu extends completely. But commenting on the code that toggles this class seems to have no effect.
http://jsfiddle.net/mblase75/5gGum/
JS:
$(document).ready(function() { $('#group-subnav > ul > li > a').on('click', function(e) { e.preventDefault(); var $li = $(this).closest('li'); $li.find('ul').slideToggle('', function() { $li.toggleClass('current') }).end().siblings().find('ul').slideUp('', function() { $li.siblings().removeClass('current') }).end(); }); });
CSS is significant and HTML is not significant.
source share