如何用JavaScript隐藏HTML元素?
使用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>热门推荐
2 破五祝福语简短的
10 女儿蛋糕祝福语简短精辟
11 对老人新年祝福语简短
12 金婚祝福语大全简短唯美
13 关于水的简短祝福语
14 冬日问候祝福语大全简短
15 退休后祝福语简短护士
16 六一祝福语简短十六字
17 送女儿礼物祝福语简短
18 节日祝福语大全简短创意