About Me

header ads

5. Script điều khiển Modal​

 <script>

    const modal = document.getElementById("myModal");

    const openBtn = document.getElementById("openModal");

    const closeBtn = document.getElementById("closeModal");


    openBtn.onclick = () => modal.style.display = "flex";

    closeBtn.onclick = () => modal.style.display = "none";

    window.onclick = (event) => {

      if (event.target === modal) modal.style.display = "none";

    };

  </script>

</body>

</html>

Đăng nhận xét

0 Nhận xét