小编use*_*474的帖子

在fadeOut之前的JQuery延迟

我写了一个jquery脚本,允许我淡入淡出div,然后重复.代码工作正常.但是,当我尝试添加延迟时(我希望div在淡出之前保持几秒钟),它无法正常工作.我已经尝试在代码中的几个地方添加延迟,似乎没有正常运行.我正在使用Jquery版本1.9.1

这是我写的脚本:

$(document).ready(function(){
   ShowPostDiv(0);
});

function ShowPostDiv(divIndex)
{
    $(".home_entry_txt").hide();

    if(divIndex >= $(".rotate_hide").length)
    {
        divIndex = 0;
    }
    var divPostHtml = $(".rotate_hide:eq("+divIndex+")").html();
    $(".home_entry_txt").html(divPostHtml); 
    $(".home_entry_txt").fadeIn(3000, function(){
             $(".home_entry_txt").fadeOut("slow");
        });
    divIndex++;
    setTimeout("ShowPostDiv("+divIndex+")", 4000);
}
Run Code Online (Sandbox Code Playgroud)

jquery delay

20
推荐指数
2
解决办法
2万
查看次数

标签 统计

delay ×1

jquery ×1