当前位置: 代码迷 >> JavaScript >> 如何延迟jquery部分,以便它们不会同时出现?
  详细解决方案

如何延迟jquery部分,以便它们不会同时出现?

热度:23   发布时间:2023-06-05 14:11:51.0

我希望先出现.title然后再出现.element然后再出现.list 但是,我似乎无法弄清楚该怎么做。 它们总是同时出现。

setTimeout(function() {
  $("#screen" + screenNum).show();
  $("#screen" + screenNum + " .title").each(function(index) {
    $(this).css("display", "block");
    TweenLite.from($(this), animationSpeed, {
      x: -1000,
      ease: Cubic.easeOut,
      delay: index * 0.1
    });
  });

  $("#screen" + screenNum + " .element").each(function(index) {
    $(this).css("display", "block");
    TweenLite.from($(this), animationSpeed, {
      y: 1080,
      ease: Cubic.easeOut,
      delay: index * 0.1
    });
  });

  $("#screen" + screenNum + " .list").each(function(index) {
    $(this).css("display", "block");
    TweenLite.from($(this), animationSpeed, {
      y: -500,
      ease: Cubic.easeOut,
      delay: index * 0.1
    });
  });
}, numEle * 100);

我可能会在jquery使用.load函数,它的作用是第二次完成加载将运行一个函数。 您可以使用它来表示仅在加载文档时运行一个函数,在页面上的对象加载时甚至在另一个javascript函数时运行。 使用它只是引用对象

$("object here").load(function); 

要么

$("object").load(function(){

});

如果您想了解更多信息, w3schools页面: :

  相关解决方案