我正在使用Jquery Modal Popup ,请参阅我正在使用的实时代码 here
按Ctrl + F5几次,您将看到div“Hello World”的内容。
为什么它首先显示这一点以及如何消除它?
下面是我正在使用的完整代码,您可以使用此 link 在这里编辑代码.
HTML
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>jQuery UI Dialog - Default functionality</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.0/themes/base/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.8.3.js"></script>
<script src="http://code.jquery.com/ui/1.10.0/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css" />
</head>
<body>
<input type="button" id="btn1" value="Open Jquery Modal Popup" />
<div id="dialog">
<h2>Hello World</h2>
</div>
</body>
</html>
JS
$(function() {
$("#dialog").dialog({
autoOpen: false,
width: 350,
modal: true,
resizable: false
});
$("#btn1").click(function(){
console.log("aa");
$( "#dialog" ).dialog("open");
})
});
最佳答案
如果您的意思是您可以在页面加载时看到 #dialog
div 然后消失,那是因为它在 DOM 加载之前是可见的,然后又隐藏了。
您可以使用 CSS 手动隐藏它,如下所示:
#dialog {
display: none;
}
dialog
插件将为您显示/隐藏它。
关于jquery - 按下 Ctrl + F5 时(即在 jquery 加载之前)显示模态对话框内容,如何摆脱它?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14559963/