简体   繁体   English

如何延迟.trigger点击事件

[英]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. 我想将在此代码的if语句中找到的.trigger(click)事件延迟5秒钟,我尝试使用.delay()但这对我没有帮助。 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');
                }
            });

delay only works on subsequent items in the queqe. delay仅适用于队列中的后续项目。 And your code does not qualify respecting to it. 并且您的代码没有资格遵守它。

Use setTimeout instead. 请改用setTimeout

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

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

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

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