I found a blog post on creating the menu found in gmail with css dropdown.
The dropdown is displayed when we hover over the buttons but I want to convert this to a jQuery menu
where the dropdown is displayed when we click on a button rather than on mouseover, Please help.
Thanks in advance .
It’s really simple logic. I replaced a few of the
:hoverCSS rules with a.clickedclass and added this JS:Instead of allowing the browser to trigger the dropdown with the
:hoverpseudo class, I have jQuery toggle the class.clickedon each top-levelliclicked. This produces the same behavior, but with JS.This line:
Basically removes the
clickedclass from the siblings of that element, which allows the user to drop down only one menu at a time (otherwise overlap occurs).Demo: http://jsfiddle.net/PSUkW/5/