我有一个模态在我的网站上工作,但我想要一个模态,但如何? 可能是工作代码链接的帮助吗?
<div id="glemsom" class="modal">
<!-- Modal content -->
<div class="modal-content">
<div class="modal-header">
<span class="close">×</span>
<h2>Glemt koden?</h2>
</div>
<div class="modal-body">
<p>Modal no 1</p>
</div>
使用此脚本:
<script>
// Get the modal
var modal = document.getElementById('glemsom');
// Get the button that opens the modal
var btn = document.getElementById("glemtkoden");
// Get the <span> element that closes the modal
var span = document.getElementsByClassName("close")[0];
// When the user clicks the button, open the modal
btn.onclick = function() {
modal.style.display = "block";
}
// When the user clicks on <span> (x), close the modal
span.onclick = function() {
modal.style.display = "none";
}
// When the user clicks anywhere outside of the modal, close it
window.onclick = function(event) {
if (event.target == modal) {
modal.style.display = "none";
}
}
</script>
如何在脚本的同一侧添加更多模态。