We Recommend

Pro JavaScript Techniques Pro JavaScript Techniques
Pro JavaScript Techniques is the ultimate JavaScript book for the modern web developer. It provides everything you need to know about modern JavaScript, and shows what JavaScript can do for your web sites. This book doesn't waste any time looking at things you already know, like basic syntax and structures.


Posted By

gbot on 03/09/08


Tagged

toggle element


Versions (?)


Who likes this?

1 person has marked this snippet as a favorite

gbot


Javascript toggle content - roScripts


Published in: JavaScript 


URL: http://www.roscripts.com/snippets/show/144

  1. <a href='javascript: toggle()'>toggle</a> <div id='div1' style='display:none'> Don't display me </div> <script>
  2.  
  3. function toggle(){ var div1 = document.getElementById('div1') if (div1.style.display == 'none') { div1.style.display = 'block' } else { div1.style.display = 'none' } } </script>

Report this snippet 

You need to login to post a comment.