Posted By

fackz on 11/17/09


Tagged

show element hide


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

fackz


Toggle (Show/Hide) Element


 / Published in: JavaScript
 

URL: http://css-tricks.com/snippets/javascript/showhide-element/

  1. <script type="text/javascript">
  2. <!--
  3. function toggle_visibility(id) {
  4. var e = document.getElementById(id);
  5. if(e.style.display == 'block')
  6. e.style.display = 'none';
  7. else
  8. e.style.display = 'block';
  9. }
  10. //-->
  11. </script>
  12.  
  13. Inline usage:
  14. <a href="#" onclick="toggle_visibility('foo');">Click here to toggle visibility of element #foo</a>
  15. <div id="foo">This is foo</div>

Report this snippet  

You need to login to post a comment.