我正在创建一个 JavaScript 小游戏。当页面加载时,它应该在页面上显示一个 Fancybox。
这是我的 Fancybox 的 jQuery:
$(document).ready(function() {
$('#test').fancybox({
'transitionIn' : 'elastic',
'transitionOut' : 'elastic',
'showCloseButton' : false,
'overlayOpacity' : 1
}).click();
});
这是我的 HTML:
<a id="test" href="#test2" style="display:none;">Test the Popup</a>
<div style="display:none;">
<div id="test2" style='padding:10px; background:#fff;width:550px;'>
<b style="color:#FF9C21;font-size:24px;">HTML Jeoprady</b><br>
<span style="font-size:15px;">
You think your good at HTML? Well test your skill here.<br>
Please know there is more to HTML than 2 tags ;)<br>
Are you ready?<br><br>
<b style="color:#FF9C21;font-size:24px;">Name:</b>
<input type="text" id="team1" />
</span>
<br><br>
<span id="start" onclick="loop();" style="cursor:pointer;color:#FF9C21;font-size:20px;">
<center>Start Game!</center></span>
</div>
</div>
我所有激活 onclick 的 FancyBox 都显示,但它会在打开后约 5 秒自动关闭。
有什么办法可以解决这个问题吗?
最佳答案
您应该只使用 .open() 而不是 .click()
编辑:我真傻,没有 .open()。我之前在触发点击程序点击事件时遇到过问题。如果您尝试的方法导致问题,请试试这个
$('#test').trigger('click')
或者使用手动调用
$.fancybox('html content here',{options})
关于javascript - FancyBox onload show 无法正常点击,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7590239/