Show Hide a Div with Javascript


/ Published in: JavaScript
Save to your folder(s)

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

<a href="#">share it</a>


Copy this code and paste it in your HTML
  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>

URL: http://ooopx.net

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.