Toggle Visibility


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



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

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.