ใช้การมองเห็น คุณสมบัติใน JavaScript เพื่อซ่อนองค์ประกอบ คุณสามารถลองเรียกใช้โค้ดต่อไปนี้เพื่อเรียนรู้วิธีทำงานกับการมองเห็น คุณสมบัติเพื่อซ่อนองค์ประกอบ -
ตัวอย่าง
<!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>