延迟后运行功能 [英] Run Function After Delay

查看:85
本文介绍了延迟后运行功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我存储了以下全局jQuery函数,但是在页面加载时,我想在1000个延迟后执行它.我的语法有问题吗?我知道延迟总是在功能之前发生.它没有响应.

I have the below global jQuery function stored, but on page load, I want to execute it after a 1000 delay. Is there something wrong with my syntax? I know the delay always goes before the function. It is not responding.

全局功能:

function showpanel() {     
       $(".navigation").hide();
       $(".page").children(".panel").fadeIn(1000);
    ;}

执行功能:

parallax.about.onload=function(){
    $('#about').delay(3000).showpanel();
};

推荐答案

$(document).ready(function() {

  // place this within dom ready function
  function showpanel() {     
    $(".navigation").hide();
    $(".page").children(".panel").fadeIn(1000);
 }

 // use setTimeout() to execute
 setTimeout(showpanel, 1000)

});

有关更多信息,请参见此处

For more see here

这篇关于延迟后运行功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆