Javascript 创建用于显示视频的模式窗口
在创建一个模态窗口并使其在单击时弹出时卡住了。模式项甚至没有显示在我的浏览器中,但它们在JSFid中显示。是浏览器还是代码?也很好奇我到底做错了什么,尝试了很多。Javascript 创建用于显示视频的模式窗口,javascript,jquery,css,html,twitter-bootstrap,Javascript,Jquery,Css,Html,Twitter Bootstrap,在创建一个模态窗口并使其在单击时弹出时卡住了。模式项甚至没有显示在我的浏览器中,但它们在JSFid中显示。是浏览器还是代码?也很好奇我到底做错了什么,尝试了很多。HTML: <section id="modals"> <button id="myBtn">Open Modal</button> <div id="myModal" class="modal"> <div> <div class="modal-
HTML:
<section id="modals">
<button id="myBtn">Open Modal</button>
<div id="myModal" class="modal">
<div>
<div class="modal-content">
<span class="close">×</span>
<div class="modal clearfix">
<div class="modal-menu">
<div class="modal-menu-item">Video</div>
<div class="modal-menu-item">Video</div>
<div class="modal-menu-item">Video</div>
<div class="modal-menu-item">Video</div>
<div class="modal-menu-item">Video</div>
<div class="modal-menu-item">Video</div>
<div class="modal-menu-item">Video</div>
</div>
<div class="modal-content">
<div class="modal-header">Header</div>
<div class="modal-body">Body</div>
<div class="modal-footer">Footer</div>
</div>
</div>
</div>
</div>
</div>
JS:
var modal = document.getElementById('myModal');
// Get the button that opens the modal
var btn = document.getElementById("myBtn");
// Get the <span> 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 <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";
}
}
var modal=document.getElementById('myModal');
//获取打开模式对话框的按钮
var btn=document.getElementById(“myBtn”);
//获取关闭模态的元素
var span=document.getElementsByClassName(“关闭”)[0];
//当用户单击该按钮时,打开模式对话框
btn.onclick=函数(){
modal.style.display=“块”;
}
//当用户单击(x)时,关闭模式对话框
span.onclick=函数(){
modal.style.display=“无”;
}
//当用户单击模式之外的任何位置时,将其关闭
window.onclick=函数(事件){
如果(event.target==模态){
modal.style.display=“无”;
}
}
如果使用的是引导模式,则必须在页面中包含JQuery库,并尝试以下隐藏/显示模式代码:
$('#myModal).modal('show'); // For displaying the modal
$('#myModal').modal('hide'); // For hiding the modal
如果您使用的是Bootstrap模式,则必须在页面中包含JQuery库,并尝试以下隐藏/显示模式代码:
$('#myModal).modal('show'); // For displaying the modal
$('#myModal').modal('hide'); // For hiding the modal
按项目中包含的顺序显示脚本标记?这些是引导模式,对吗?按项目中包含的顺序显示脚本标记?这些是引导模式,对吗?