View Single Post
Old Nov 8th, 2007, 1:13 PM   #4
big_k105
PFO Founder

 
big_k105's Avatar
 
Join Date: Mar 2004
Location: Fargo, ND
Posts: 1,613
Rep Power: 10 big_k105 is on a distinguished road
Send a message via AIM to big_k105 Send a message via MSN to big_k105 Send a message via Yahoo to big_k105
Re: .style.visibility = 'visible';

@dani: He isn't using the display attribute, he is using the visibility attribute of style which does contain hidden and visible.

@paulchwd: I am not sure what is wrong, but from the looks of it, it is exactly what I did below and it works for me. http://www.kylekonline.com/test/visible.html <= if you want to see it working.
html Syntax (Toggle Plain Text)
  1. <html>
  2. <head>
  3. <title>Test Javascript</title>
  4. <script type="text/javascript" language="javascript">
  5. function showFirst()
  6. {
  7. var xx;
  8. xx = document.getElementById('xx');
  9. xx.style.visibility = 'visible';
  10. }
  11.  
  12. function hideFirst()
  13. {
  14. var xx;
  15. xx = document.getElementById('xx');
  16. xx.style.visibility = 'hidden';
  17. }
  18.  
  19. function showSecond()
  20. {
  21. var yy;
  22. yy = document.getElementById('yy');
  23. yy.style.display = 'block';
  24. }
  25.  
  26. function hideSecond()
  27. {
  28. var yy;
  29. yy = document.getElementById('yy');
  30. yy.style.display = 'none';
  31. }
  32. </script>
  33. </head>
  34. <body>
  35. <a href="javascript:;" onClick="showFirst()">Show First Div</a><br />
  36. <a href="javascript:;" onClick="hideFirst()">Hide First Div</a><br />
  37. <div id="xx">This is the first div called xx</div>
  38.  
  39. <br /><br />
  40.  
  41. <a href="javascript:;" onClick="showSecond()">Show Second Div</a><br />
  42. <a href="javascript:;" onClick="hideSecond()">Hide Second Div</a><br />
  43. <div id="yy">This is the second div called yy</div>
  44. </body>
  45. </html>
__________________
BIG K aka Kyle
Programming Forums
Kyle K Online

Please do not PM or email me programming questions. Post them in the forums instead.
big_k105 is offline   Reply With Quote