I have two jQuery menu's that properly show when clicking on "show".
For example let's say you have two links:
"Show 1", "Show 2"
You click on "Show 1" and then a div appears with "show 1 content"
You click on "Show 2" and then a div appears with "show 2 content"
I have it working to that point.
Obviously there is a couple usability things I need to tackle. If I click on "Show 1" and then click on "Show 2" I want "Show 1's Content" to disappear (hide the "show 1 content" div)
One other thing, if I click anywhere on the page, whichever dropdown is active I want it to hide if I click outside the content box.
My dom structure:
ul
li.menu
span= link_to 'Show 1'
ul.dropdown.hidden
li= link_to 'show 1 content'
li.menu
span= link_to 'Show 2'
ul.dropdown.hidden
li= link_to 'show 2 content'
My js:
$("#search li.menu span a").click(function(event) {
event.preventDefault();
$(this).parent().siblings("ul.dropdown").toggleClass("hidden");
});
So basically I just need to understand how to apply hidden when clicking outside of the ul.dropdown box and how to apply hidden when clicking an OTHER ul.dropdown box
Thanks.