Kaio Loureiro
Kaio Loureiro

Reputation: 9

jQuery: User must stay on page for determined time to show content

I'm having some problems with my code. As you can see below, the content of the post will only be shown if the user click on the link provided. It will unlock an action. But I need that the user must stay on the page for at least some seconds before unlock the content. If the user leave the page before this determined time, the content won't be show. Any way to do it?

jQuery(document).ready(function(){
var clicked = new Set;

  jQuery('.Button').click(function() {
     clicked.add(this);
        if(clicked.size>=10) jQuery('.PageLocked').hide();
        if(clicked.size>=10) jQuery('.Content').show();
     });
});

Upvotes: 0

Views: 105

Answers (1)

jgjr
jgjr

Reputation: 55

Perhaps you could just use a setTimeout to display the content after a certain length of time.

$('.Button').click(function() {
    setTimeout(function() { 
        $('.PageLocked').hide();
        $('.Content').show();
    },10000); 
});

Upvotes: 1

Related Questions