我想在按下按鈕時更改DIV的可見性。什麼是錯,此代碼 如何更改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>
謝謝先生@Barmar –