这是我的代码:
if (document.getElementById("hiddenButton").style.visibility != "visible") {
document.getElementById("hiddenButton").style.visibility = "visible";
}
else {
document.getElementById("hiddenButton").style.visibility = "hidden";
}
当您单击另一个按钮时,此代码显示和隐藏 HTML 按钮。
但是我的问题是为什么该代码有效,而这无效:
if (document.getElementById("hiddenButton").style.visibility = "hidden") {
document.getElementById("hiddenButton").style.visibility = "visible";
}
else {
document.getElementById("hiddenButton").style.visibility = "hidden";
}