我想在页面加载时打开Reveal Modal Popup,而不点击任何内容
以下是:
<!DOCTYPE html>
<head>
<title>Modal PopUp</title>
<link type="text/css" rel="stylesheet" href="css/style.css">
<link type="text/css" rel="stylesheet" href="css/reveal.css">
<script type="text/javascript" src="http://code.jquery.com/jquery-1.6.min.js"></script>
<script type="text/javascript" src="js/jquery.reveal.js"></script>
<script language="JavaScript">
$(function() {
$( "#myModal" ).dialog();
});
</script>
</head>
<body>
<!-- #reveal modal popup -->
<div id="myModal" class="reveal-modal">
<h1>Reveal Modal Goodness</h1>
<p>This is a default modal in all its glory, but any of the styles here can easily be changed in the CSS.</p>
<a class="close-reveal-modal">×</a>
</div>
<!-- #reveal modal popup -->
</body>
</html>
我不想使用此触发器:
<a href="#" data-reveal-id="myModal">Click Me For A Modal</a>
它应该自动打开。
答案 0 :(得分:3)
试试这个
$(document).ready(function() { //or $(window).load(function(){
$('#myModal').reveal($(this).data());
});
答案 1 :(得分:1)
您可以隐藏锚标记并以编程方式单击它:
<a href="#" id="clickMe" data-reveal-id="myModal" style="display:none;">Click Me For A Modal</a>
$('#clickMe').click();
它将打开而不点击页面上的任何链接或按钮,但在后面我们以编程方式单击它。
你也可以这样做:
$("#myModal").reveal();