I am trying to show a div
using javascript
when a user clicks on another div
.
Here is my code, its working fine, except, I need it to work the other way around. The div
is visible on load and hidden once the user clicks the other div
.
<div id="content_nav">
<div class="login_heading">Logged in as, <strong><?php echo $_SESSION['user'];?>>/strong>, <a href="logout.php">Logout</a></div>
<div class="control_panel">
<div id="ctrl1" onclick="toggle();"></div>
<p class="control">(0) Messages</p>
<div id="msg_menu"></div>
<script>
var toggle = function() {
var mydiv = document.getElementById('msg_menu');
if (mydiv.style.display === 'none' || mydiv.style.display === '')
mydiv.style.display = 'block';
else
mydiv.style.display = 'none'
}
</script>
css:
#msg_menu{
margin:auto;
width:990px;
height:200px;
background:#000;
}