This menu works well on desktop but when I switch to mobile, I would like the menu to slideUp when the ul is clicked. So far, the menu slides up when a user clicks on the top / main menu. It is fine, but I'd like to have a better user experience by sliding / fading the sub menus.
1 Answer
I don't know if you needed that other jQuery, but I just added the html into the doc and replaced your javascript with this:
$('#menu-button').on("click", function () {
$('#cssmenu ul').slideToggle();
});
Taking advantage of jQuery's slideToggle() functionality.
Here's the fiddle: http://jsfiddle.net/16cq72ms/3/
6 Comments
telo78
Thanks @pgruber I had tried the slideToggle function but I would like to do it on the parent and ul li menus. I would also like to slide the ul li and return to the main menu after clicking.
Platte Gruber
@telo78 So clicking on the dropdown would also slide the element up? Check out my updated fiddle and let me know if I'm on the right track.
telo78
damn, that was easy. i was using slideToggle on both selectors. thanks so much! i will update my code accordingly. :)
Platte Gruber
Glad it worked! I actually just cleaned it up so it should be even cleaner now.
telo78
i'll check the desktop version. it shouldn't toggle tho. but yeah works nice and simple.
|