<分区>
我想在按下按钮时更改 DIV 的可见性。这段代码有什么问题
<p id="myP">This is a p element.</p>
<button type="button" onclick="myFunction()">Hide content of p</button>
<script>
function myFunction() {
var which= document.getElementById("myP");
if (which.style.visibility=="visible")
which.style.visibility = "hidden"
else
which.style.visibility = "visible"
}
</script>
</body>