Dynadot โ€” .com Transfer

Onclick html code

Spaceship Spaceship
Watch
Impact
7
I'm looking for onclick code where if a user click on a button it closes the div.

<button type="button" onclick="this.style.visibility='hidden'">Close to play</button>

The code I have closes the button itself, but not the div. Any suggestions?
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
.US domains.US domains
This is how I've done it in the past

Code:
<SCRIPT language="JavaScript">
<!--
function ToggleVisibility(DivID){
  if(document.getElementById(DivID).style.display == 'none'){
    document.getElementById(DivID).style.display = 'block';
  }
  else{
    document.getElementById(DivID).style.display = 'none';
  }
}
//-->
</SCRIPT>



<DIV Onclick="ToggleVisibility('menu1')" Style="cursor:hand; cursor:pointer">click</DIV>
<div id="menu1" class='menu' style="display:none;">
Link 1<br/ >
Link 2<br/ >
</div>

This way you can add as many links and divs as you want and have them run from the same function.
 
1
•••
Thanks! ..works like a charm
 
0
•••
if you want to add some flair to the way it's hidden (or if you want to toggle it in an easier way as a show/hide button), check out jQuery. it's a library that allows you to show/hide with just a few lines of code, and it has cool effects.
 
0
•••
Dynadot โ€” .com TransferDynadot โ€” .com Transfer
Domain Recover
DomainEasy โ€” Payment Flexibility
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back