简体   繁体   English

添加一个延迟jQuery揭示弹出

[英]Add a delay a jquery reveal popup

Live site- http://www.uposonghar.com/test/test_popup.html 实时网站-http : //www.uposonghar.com/test/test_popup.html

Reveal popup js page- http://www.uposonghar.com/test/jquery.reveal.js 显示弹出式js页面-http : //www.uposonghar.com/test/jquery.reveal.js

Due to a lot of code on js page maybe that is not a good option to post all js code here. 由于js页面上的代码很多,可能不是在此处发布所有js代码的好选择。

I want to add 10 second delay on that popup so if anyone click on link then popup will appears after 10 second. 我想在该弹出窗口上添加10秒延迟,因此如果有人单击链接,则弹出窗口将在10秒后出现。 I tried JavaScript settimeout but doesn't work, due to low knowledge of jQuery i don't know how to do that with jquery. 我尝试了JavaScript settimeout,但是由于对jQuery的了解不足而无法正常工作,因此我不知道如何使用jQuery。 Also popup doesn't appears if i click on on second time, only appears on when i click on first time. 如果我第二次单击,也不会出现弹出窗口,只有当我第一次单击时才会出现。

setTimout solves that beautifully. setTimout解决了这一问题。 Try that... 试试看...

var tmrReveal = null;    
$('a[data-reveal-id]').live('click', function(e) {
    e.preventDefault();
    var modalLocation = $(this).attr('data-reveal-id');
    if (tmrReveal != null)
            clearTimeout(tmrReveal);

    tmrReveal = setTimeout(
        function() {
           $('#'+modalLocation).reveal($(this).data()); 
        },10000);
});

Use setTimeout() 使用setTimeout()

setTimeout(function() {
      //code goes here
}, 10000);
$('#your-anchor-here').click(
function(){
    setTimeout(
        function(){
            //popup logic here
        },10000)
      });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM