如何在我的html页面中添加第二个模态
我在上一篇文章中没有解释我的问题。
所以我想在我的html页面添加第二个模态,所以如果你点击“按钮1”它将打开“模态1”,如果你点击“按钮2”它将打开“模态2”然而“按钮3”“按钮4“”按钮5“和”按钮6“打开”模态2“。 当我创建第二个模态并在下面设置javascript。 它将在两个按钮上保持打开模态2,而不是按钮1上的模态1。
另请注意,第一个按钮“免费”的ID
另请注意,第二个按钮“oneday”的ID
// Get the modal1 var modal = document.getElementById('myModal1'); // Get the button that opens the modal var btn = document.getElementById("free"); // Get the element that closes the modal var span = document.getElementsByClassName("close")[0]; // When the user clicks on the button, open the modal btn.onclick = function() { modal.style.display = "block"; } // When the user clicks on (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"; } } // Get the modal2 var modal = document.getElementById('myModal2'); // Get the button that opens the modal var btn = document.getElementById("oneday"); // Get the element that closes the modal var span = document.getElementsByClassName("close")[0]; // When the user clicks on the button, open the modal btn.onclick = function() { modal.style.display = "block"; } // When the user clicks on (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"; } }
当按钮1设置为“Modal1”HTML下面时,两个按钮都保持打开“Modal2”
按钮1
So you can get a taste of the action for free, we will give new users a 5 day trial to see how they like our bot before they buy!
按钮2
$0.74 -24 Hours
而模仿就在这里
Modal1
Modal2