I have a link which is clicked on to show a div menu. The div menu should close when the document is clicked on.
So here is the simple layout…
[CODE]
<head>
<script type=”text/javascript”>
hide_menu(){
document.getElementById(‘menu’).style.display = ‘none’;
}
document.onclick = function(){ hide_menu(); }
show_menu(){
document.getElementById(‘menu’).style.display = ”;
}
</script>
</head>
<body>
<a href=”javascript:void(0);” onclick=”show_menu();”>
<div id=”menu”></div>
</body>
The problem is the document.onclick hide_menu() event is OVERRIDING the link’s onclick show_menu() event. The div menu never shows! ?
How can this be resolved? I tried addEventListener and couldn’t get it to work.