Dynadot Aftermarket: discover domain gems worth investing in. Visit our aftermarket.

Onclick html code

SpaceshipSpaceship
SpaceshipSpaceship
Namecheap AuctionsNamecheap Auctions
Watch

Sohil

VIP Member
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
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
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
Close
Thanks! ..works like a charm
 
0
Close
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
Close
DomainEasy: white label portfolios are live. Enable yours.

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Filters for activity feeds
Your news feed, Latest activity, and the activity tab on profiles now have filter buttons: All, Posts, Quick replies, and Other. Your...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back