Javascript toggle a div layer visibility


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



Copy this code and paste it in your HTML
  1. function toggleLayer(whichLayer) {
  2. if (document.getElementById) {
  3. var style2 = document.getElementById(whichLayer).style;
  4. style2.display = style2.display? "":"block";
  5. } else if (document.all) {
  6. var style2 = document.all[whichLayer].style;
  7. style2.display = style2.display? "":"block";
  8. } else if (document.layers) {
  9. var style2 = document.layers[whichLayer].style;
  10. style2.display = style2.display? "":"block";
  11. }
  12. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.