Javascript examples for CSS Style Property:display
Toggle between showing and hiding an element:
<!DOCTYPE html> <html> <head> <style> #myDIV {// w ww. ja v a 2s . co m width: 200px; height: 200px; background-color: red; } </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.display === 'none') { x.style.display = 'block'; } else { x.style.display = 'none'; } } </script> </body> </html>