First of all sorry if this is a redundant question. But I am having some issues.
In a nutshell, the show div section works as expected. It's the part where I click outside the div to close it that it fails. And when it fails it also disables the show() from working.
Here is a high level overview of the code. Notice the element id's
<div>
<div id='expandmenu' ><button image to click></div>
</div>
The dropcontent class is basically display:none;
<div id='mymenu' class='dropcontent'>
<a href .... >Choice 1</a>
<a hrfe .... >Choice 2</a>
.
.
.
</div>
my script file contains the following.
$(document).ready(function(){
$("#expandmenu").click( function(e) {
$('#mymenu').show();
});
.
.
.
});
This code works fine and when I click on the button image the menu is displayed as expected.
However, I would like to click outside of the menu to have the "mymenu" div close.
I wont include most of the code I have tried because they all fail. My friend sent me this code and it also fails
$("body").not("#expandmenu").click( function() {
$('#mymenu').hide();
});
I am thinking that the click on body supersedes everything and hides the menu even if you try to open it.
Any suggestions in simple form would be appreciated. I am so new to js stuff.
Thanks
JT