Jump to content

Open And Close Div Tag With Button Help


Mancent

Recommended Posts

Hi I have this div tag name id one and id two and I can get teh div tag to open to show the div tag two, but i can not get it to close.

 

heres what I got!

 

If you look on my page http://wiistream.com

you will see a please help button at the top, and if you click it it opens the donations panel!

 

what i want to do is, if you click the please help button again make it close the donation panel.

 

 

button:

<span class="btn4" onclick="javascript:showDiv();"><a href="#"></a></span>

 

JS

<script type="text/javascript">



function showDiv()
{
div = document.getElementById('two');
div.style.display = "block";

}
function hideDiv()
{
div = document.getElementById('two');
div.style.display = "none";
}
</script>

 

 

Any ideas how to do this? im new to JS

 

i thought I could make a simple switch's function in the JS script.

that the button calls and have if statement of some sort!

 

function hideDiv_And_showDiv()
{
if(SOMETHING?)
{
div = document.getElementById('two');
div.style.display = "none";
}
else
{
div = document.getElementById('two');
div.style.display = "block";
}
}

Link to comment
https://forums.phpfreaks.com/topic/271305-open-and-close-div-tag-with-button-help/
Share on other sites

function showDiv_And_hideDiv() 
 {
  if(document.getElementById('two').style.display=='block')
  {
           div = document.getElementById('two');
           div.style.display = "none";
  }
  else
  {
   div = document.getElementById('two');
           div.style.display = "block";
  }

       }

 

NVM Got it!

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.