我试图在单击按钮 ( ) 时关闭我的模式框 (#newspopup <div class="visitwebsitebtn">Click here to enter</div>
)?我试过
<script>
$(document).on('click', '.visitwebsitebtn', function() {
$.fancybox.close();
});
</script>
但没有成功。对此有什么想法吗?非常感谢
花式代码:
<script type="text/javascript">
function openFancybox() {
setTimeout( function() {$('#newspopup').trigger('click'); },2000);
}
$(document).ready(function() {
var visited = $.cookie('visited');
if (visited == 'yes') {
return false;
} else {
openFancybox();
}
$.cookie('visited', 'yes', { expires: 0.0001 });
$('#newspopup').fancybox({
helpers : {
overlay : {
css : {
'background' : 'rgba(58, 42, 45, 0.3)'
}
}
}
});
});
</script>
关闭脚本:
<script>
$(document).on('click', '.visitwebsitebtn', function() {
$.fancybox.close();
});
</script>
盒子:
<div id="newspopup" style="display:none;">
<h2>Latest news</h2>
<p>blablabla</p>
<div class="visitwebsitebtn">Click here to enter</div>
</div>