arifix
arifix

Reputation: 750

Add a delay a jquery reveal popup

Live site- http://www.uposonghar.com/test/test_popup.html

Reveal popup js page- 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.

I want to add 10 second delay on that popup so if anyone click on link then popup will appears after 10 second. I tried JavaScript settimeout but doesn't work, due to low knowledge of jQuery i don't know how to do that with jquery. Also popup doesn't appears if i click on on second time, only appears on when i click on first time.

Upvotes: 0

Views: 191

Answers (3)

Adam Rehill
Adam Rehill

Reputation: 763

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

Upvotes: 0

Roger Barreto
Roger Barreto

Reputation: 2284

setTimout solves that beautifully. 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);
});

Upvotes: 1

victorantunes
victorantunes

Reputation: 1169

Use setTimeout()

setTimeout(function() {
      //code goes here
}, 10000);

Upvotes: 0

Related Questions