Jump to content

[SOLVED] JS & CSS drop menu.


Brian W

Recommended Posts

I'm trying to get this script to work and can't figure out what it wrong, what doesn't surprise me... I don't have really any experience writing my own JS.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Test Drop Menu</title>
<style type="text/css">
<!--
.content {
display: none;
width: 99%;
height: 320px;
padding: 4px;
border: 1px dotted black;
background-color: white;
z-index:102;
overflow: auto;
}
.lightbox {
font-size: 16px;
font-weight: bold;

}
.lightbox  a {
text-decoration: none;
color:#FF0000;
}
-->
</style>
</head>

<body>
<a href = "javascript:void(0)" onclick = "
if (document.getElementById('light').style.display == 'none')
{
document.getElementById('light').style.display='block';
    }
if (document.getElementById('light').style.display == 'block')
{
document.getElementById('light').style.display='none';
}
">Open</a>
<div id="light" class="content">
<div align="left" class="lightbox">
<strong>
<br />
<br />
<a href = "javascript:void(0)" onclick = "document.getElementById('light').style.display='none';"> [Close] </a>
<br />
<br />
</strong>
</div>
</div>
</body>
</html>

I'm trying to have the "Open" link open and then close the menu... I have a working version of where "Open" opens it and "Close" closes it... but I'd like to have the Open button do both.

I think the problem is with my if statements.

 

Link to comment
https://forums.phpfreaks.com/topic/128549-solved-js-css-drop-menu/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.