jQuery 延迟() 或 setTimeout()

标签 jquery jquery-events

如果你能帮助我,请;我需要在新选项卡(或窗口)中打开链接,但仅在执行了一些功能之后。我尝试了一切,纯 JavaScript、jQuery,没有任何效果。 提供的解决方案是使用 delay() 还是使用 setTimeout() 对我来说并不重要。 我认为 delay() 的问题在于它只适用于 fx 队列中的函数,我尝试了一些方法,但就是无法让它工作。

这是代码:

$(function(){

   $(“#playNowLink”).click(function() {

   $(‘#header’).effect(“fold”, { size: “50%” }, 1000);

   $(‘#showVideo’).delay(1100).fadeIn(‘slow’);

   // Here I would like to call ‘playNow.html’,
   //but only after 7-8 seconds


});

最佳答案

setTimeout(function(){

   //whatever the heck you want do to:

   //open window:
   window.open('new_window_url');

   //change location?
   window.location = "new_location_url";

}, 7500); //7.5 seconds

关于jQuery 延迟() 或 setTimeout(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7882328/

相关文章:

javascript - jQuery 和 Ajax 加载图像

javascript - 为什么提交事件中出现 'return false;' 语句?

javascript - jQuery 自定义事件未触发或触发

javascript - 我可以将函数绑定(bind)到父窗口的onscroll事件吗?

javascript - 对象在 JavaScript 中没有方法错误

javascript - Backbone JS 事件未触发

javascript - JQuery 范围 slider 工具提示

javascript - Codeigniter ajax 调用无法正常工作

javascript - 如何响应 "shown.bs.collapse"事件?

javascript - 使用 jQuery 触发动态自定义事件