Div tags - on / off
Must be super easy for you guys ... div one clicked, div two appears. What I don't know how to do is make div 2 go away when the div button is clicked again.
<img src="/..." width="" height"" onClick="MM_showHideLayers('logo','','show','logoEasterEgg','',show')">
What should I add to this line of code to make the "logoEasterEgg" div disappear when the image in div 1 is clicked again?
source to share
You will need to add another function call to hide the other div after the first call to show it.
The onclick attribute will look something like this:
MM_showHideLayers ('logo', '', 'show', 'logoEasterEgg', '', show '); hide_function ();
The onclick attribute will allow you to use as much javascript as you like, you can overlay as many functions as you like - just don't forget about your semicolons.
Edit:
After reading a little about MM_showHideLayers
, I think you need to change the function to close the div that needs to be closed. In other words, if you want to close logo
then create an onclick attribute (note the hide ):
MM_showHideLayers ('logo', '', ' hide ', 'logoEasterEgg', '', show ');
source to share
Instead of using MM_showHideLayers (), you could do something like this ...?
function toggleDiv(divId)
{
var myDiv = document.getElementById(divId);
if (myDiv)
{
if (myDiv.style.display === 'none')
{
myDiv.style.display = 'block';
}
else
{
myDiv.style.display = 'none';
}
}
}
<img src="/..." width="" height"" onClick="toggleDiv('logoEasterEgg')">
source to share