Lulutho Mgwali
Lulutho Mgwali

Reputation: 903

How to delay the .trigger click event

Id like to delay the the .trigger(click) event found in the if statement of this code by 5 seconds i have tried .delay() but this has not helped me. anyone can help me with delaying this event:

(document).ready(function () {
                var test = $("[id$=Hidden_Results]").val();
                var data = JSON.parse(test);
                if (data.level == 2 && data.roundCounter == 1) {

                    $(".hidden_ResultValues").fancybox().trigger('click');
                }
            });

Upvotes: 2

Views: 2285

Answers (1)

Sushanth --
Sushanth --

Reputation: 55750

delay only works on subsequent items in the queqe. And your code does not qualify respecting to it.

Use setTimeout instead.

$(".hidden_ResultValues").fancybox();

setTimeout(function() {
   $(".hidden_ResultValues").trigger('click');
}, 5000);

Upvotes: 3

Related Questions