Posted By

benrudolph on 03/29/10


Tagged

javascript visibility


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

benrudolph


Toggle Visibility


 / Published in: JavaScript
 

URL: http://blog.movalog.com/a/javascript-toggle-visibility/

  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. <a href="#" onclick="toggle_visibility('foo');">Click here to toggle visibility of element #foo</a>
  14. <div id="foo">This is foo</div>

Report this snippet  

You need to login to post a comment.