【问题标题】:sequentially delayed fading in with jquery使用 jquery 顺序延迟淡入
【发布时间】:2012-06-28 17:02:19
【问题描述】:

我有一些从 ajax 调用返回的数组数据,其中包括一个图像链接、一些标题文本和一个链接。我通过使用 jQuery append 方法和淡入将这个数组的每个元素添加到页面上的一个 div 中。因为它执行得如此之快,所有元素同时淡入。我希望每个都按顺序淡入。因此,当元素添加到主 div 时,淡入然后暂停 .each 语句大约 100 毫秒,然后再添加下一个元素。但是我不确定如何做到这一点。有任何想法吗?这是我的代码。

jQuery.each(data.themes, function (index){

    theme_html = "<div class=\"themePreviewWrap\" id=\"theme_" + index + "\" style=\"display:none;\"><div class=\"themePreview\"><img src=\"" + data.themes[index]['custom_color_screenshot'] + "\" /></div><div class=\"themePreviewButtom\"><div class=\"title\"><b>" + data.themes[index]['title'] + "</b></div><div class=\"link\">" + data.themes[index]['actions'] + "</div></div></div></div>";

    jQuery('#themeholder').append(theme_html);

    jQuery("#theme_" + index).fadeIn(500);

});

【问题讨论】:

    标签: jquery


    【解决方案1】:

    类似这样的:

    jQuery("#theme_" + index).delay(index * 1000).fadeIn(500);
    

    【讨论】:

      猜你喜欢
      • 2012-12-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-05-16
      • 2021-04-11
      • 1970-01-01
      • 2014-12-30
      相关资源
      最近更新 更多