Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我如何通过点击一个按钮,使用javascript将多个模态转换到网页上? 按钮1 &时代; 这是事件模式_Javascript_Html_Css_Ejs - Fatal编程技术网

我如何通过点击一个按钮,使用javascript将多个模态转换到网页上? 按钮1 &时代; 这是事件模式

我如何通过点击一个按钮,使用javascript将多个模态转换到网页上? 按钮1 &时代; 这是事件模式,javascript,html,css,ejs,Javascript,Html,Css,Ejs,情态体中的一些文本 其他一些文本 模态页脚 上面是单一模式的示例html。我想delagate 4个模态,每次单击与该模态相关的按钮时,每个模态都会弹出(在所附图片中显示的示例侧栏中)。 下面是示例js代码。我不知道iframe是否可以提供此功能 <button id="eventbtn2" class="mybtn" name="button">Button1</button> <div id=&quo

情态体中的一些文本

其他一些文本

模态页脚 上面是单一模式的示例html。我想delagate 4个模态,每次单击与该模态相关的按钮时,每个模态都会弹出(在所附图片中显示的示例侧栏中)。 下面是示例js代码。我不知道iframe是否可以提供此功能

<button id="eventbtn2" class="mybtn" name="button">Button1</button>
<div id="myeventModal" class="eventsmodal">
  <!-- Modal content -->
  <div class="modalevents-content">
    <div class="modalevents-header">
      <span class="close">&times;</span>
      <h2>This is the events modal</h2>
    </div>
    <div class="modalevents-body">
      <p>Some text in the Modal Body</p>
      <p>Some other text...</p>
    </div>
    <div class="modalevents-footer">
       <h3>Modal Footer</h3>
    </div>
  </div>
</div>
var modal=document.getElementById(“myeventModal”);
//获取打开模式对话框的按钮
var btn=document.getElementById(“eventbtn2”);
//获取关闭模态的元素
var span=document.getElementsByClassName(“关闭”)[0];
//当用户单击该按钮时,打开模式对话框
btn.onclick=函数(){
modal.style.display=“块”;
}
//当用户单击(x)时,关闭模式对话框
span.onclick=函数(){
modal.style.display=“无”;
}
//当用户单击模式之外的任何位置时,将其关闭
window.onclick=函数(事件){
如果(event.target==模态){
modal.style.display=“无”;
}
}

var modal = document.getElementById("myeventModal");
    
// Get the button that opens the modal
var btn = document.getElementById("eventbtn2");
    
// 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";
  }
}