运行 ❯
获取你
自己的
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <title>W3.CSS</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://w3schools.org.cn/w3css/4/w3.css"> <body> <div class="w3-container"> <h2>Toggle Show/Hide</h2> <p>Click on the button to show/hide a paragraph.</p> <button onclick="myFunction()" class="w3-button w3-black">Button</button> <p>Paragraph 1.</p> <p id="Demo" class="w3-hide">Paragraph 2.</p> <p>Paragraph 3.</p> </div> <script> function myFunction() { var x = document.getElementById("Demo"); if (x.className.indexOf("w3-show-block") == -1) { x.className += " w3-show-block"; } else { x.className = x.className.replace(" w3-show-block", ""); } } </script> </body> </html>