simple toggle html element


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



Copy this code and paste it in your HTML
  1. <style type="text/css">
  2. .divHide{display:none;}
  3. .divShow{display:block;}
  4. </style>
  5. <script type="text/javascript" language="javascript">
  6. function showhide(obj) {
  7. var el=document.getElementById(obj);
  8. if (el.className == "divHide") {
  9. el.className = "divShow";
  10. } else {
  11. el.className = "divHide";
  12. }
  13. }
  14. </script>
  15. ...
  16. <a onclick="showhide('calendar');" href="#calendar">click here</a>.</p><a name="calendar"></a>
  17. <div id="calendar" class="divHide"></div>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.