I'm making a navigation menu for my website. I wanted it to look like Facebook's top navigation. The menu expands only when it's clicked and disappears when you click somewhere else.
I seem have found a way to expand the list by clicking the #menu, but it won't disappear after that. I have no idea how to do so. I'm new to jQuery. I've tried to use and implement the 'if else' jQuery function, but still have no result.
Here's the jQuery listing code:
$(function() {
// OPACITY OF BUTTON SET TO 50% and DISPLAY LIST AS NONE
$("#menu").css("opacity","0.5");
$(".list").css("display","none");
// ON MOUSE CLICK
$("#menu").click(function () {
// SET OPACITY TO 100% and DISPLAY LIST
$(this).stop().animate({ opacity: 1.0 }, "slow");
$(".list").css("display","inline");
});
});
and the HTML is simply:
<div id="menu">
<a href="where.com"><span class="menu">MENU</span></a>
</div>
Thanks for helping... regards