Posted By

nerdsane on 02/03/09


Tagged

show div toggle hide


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

johnnytoobad


Show Hide a Div with Javascript


 / Published in: JavaScript
 

URL: http://ooopx.net

this code snippet will let u show/ hide a div element easily.

share it

  1. <script language="javascript">
  2. <!--
  3. var state = 'none';
  4.  
  5. function showhide(layer_ref) {
  6.  
  7. if (state == 'block') {
  8. state = 'none';
  9. }
  10. else {
  11. state = 'block';
  12. }
  13. if (document.all) { //IS IE 4 or 5 (or 6 beta)
  14. eval( "document.all." + layer_ref + ".style.display = state");
  15. }
  16. if (document.layers) { //IS NETSCAPE 4 or below
  17. document.layers[layer_ref].display = state;
  18. }
  19. if (document.getElementById &&!document.all) {
  20. hza = document.getElementById(layer_ref);
  21. hza.style.display = state;
  22. }
  23. }
  24. //-->
  25. </script>

Report this snippet  

You need to login to post a comment.