Javascript examples for CSS Style Property:visibility
Toggle between hiding and showing an element:
<!DOCTYPE html> <html> <head> <style> #myDIV {// ww w. j a v a2 s. c om width: 500px; height: 500px; background-color: lightblue; } </style> </head> <body> <button onclick="myFunction()">Test</button> <div id="myDIV"> This is my DIV element. </div> <script> function myFunction() { var x = document.getElementById('myDIV'); if (x.style.visibility === 'hidden') { x.style.visibility = 'visible'; } else { x.style.visibility = 'hidden'; } } </script> </body> </html>