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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.