View Single Post
  #1 (permalink)  
Old 08-16-05, 02:12 PM
perleo perleo is offline
Coding Addict
 
Join Date: Jul 2003
Location: Ireland
Posts: 269
Thanks: 0
Thanked 0 Times in 0 Posts
Change <div> visibility

How do I get JS to change a <div> 's visibility,

I have:

<div id="main" style="visibility: show">

but I want a link like this

<a href="#" onclick="switchMain()">Change</a>

and clicking on that link will hide or show the layer.

I tried

Code:
 function getStyle()
   {
      var temp = document.getElementById("main").style.visibility;
  
      return temp;
   }

 function switchMain()
  {

      var current = getStyle();

      if( current == "show" )
       {
         document.getElementById("main").style.visibility = "hidden";
       }
       else
       {
         document.getElementById("main").style.visibility = "show";
       }
  }
but it doesnt work ? ?
Reply With Quote