Jump to content

Show/Hide Script


knuckledog
 Share

Recommended Posts

Hi There:I am as stupid as 2 short planks. I have been trying to develop a similar script to this for months. My efforts have been less than rewarding :) :) If you dont believe me see my post in the Javascript section of this website. Anyway, to cut a long story short, where can I find this script, it seems to work wonderfully.Knuckle

Link to comment
Share on other sites

Well, it can be done many ways, here's a simple way to make a show/hide box.This goes in the head:

<script type="text/javascript">window.onload = function() {document.getElementById('content').style.display = "none";/* If Javascript is deactivated the box will be shown by default */}function toggle(L,id) {   obj = document.getElementById(id);   (obj.style.display=="none")?disp = "block":disp = "none";   if(disp == "block") {	  N = "Hide";   } else {	  N = "Show";   }   obj.style.display = disp;   L.firstChild.nodeValue = N;}</script>

This goes in the body:

<a href="javascript:void(0);" onclick="toggle(this,'something')">Show</a><div id="something">Some content</div><a href="javascript:void(0);" onclick="toggle(this,'somethingelse')">Show</a><div id="somethingelse">Some content</div>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...