运行 ❯
获取您的
自有
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <head> <style> #myDIV { margin: auto; width: 400px; height: 200px; background-color: lightblue; border: 1px solid black; } </style> </head> <body> <h1>Change visibility with JavaScript</h1> <p>Click the "Try it" button to set the visibility property of the DIV element to "hidden":</p> <button onclick="myFunction()">Try it</button> <div id="myDIV">This is my DIV element.</div> <p><strong>Note</strong>: Hidden elements still take up space on the page.</p> <script> function myFunction() { document.getElementById("myDIV").style.visibility = "hidden"; } </script> </body> </html>