使用JavaScript中的visible 属性可显示元素。您可以尝试运行以下代码,以了解如何使用能见度 属性:
<!DOCTYPE html> <html> <body> <p id="pid">Demo Text</p> <button type = "button" onclick = "displayHide()"> Hide </button> <button type = "button" onclick = "displayShow()"> Show </button> <script> function displayHide() { document.getElementById("pid").style.visibility = "hidden"; } function displayShow() { document.getElementById("pid").style.visibility = "visible"; } </script> </body> </html>