Brian W Posted October 15, 2008 Share Posted October 15, 2008 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 More sharing options...
Brian W Posted October 15, 2008 Author Share Posted October 15, 2008 I figured it out... has to add style="display:none;" in my div. I also fiddled with my JS, but don't know if that helped. Thanks anyways. Link to comment https://forums.phpfreaks.com/topic/128549-solved-js-css-drop-menu/#findComment-666211 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.