📜  隐藏 div - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:02.263000             🧑  作者: Mango

代码示例4
const targetDiv = document.getElementById("third");
const btn = document.getElementById("toggle");
btn.onclick = function () {
  if (targetDiv.style.display !== "none") {
    targetDiv.style.display = "none";
  } else {
    targetDiv.style.display = "block";
  }
};