gpt4 book ai didi

淡出前的 JQuery 延迟

转载 作者:行者123 更新时间:2023-12-03 21:45:26 30 4
gpt4 key购买 nike

我编写了一个 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);
}

最佳答案

你可以直接写

$(".home_entry_txt").fadeIn(3000).delay(1000).fadeOut("slow");

关于淡出前的 JQuery 延迟,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15686598/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com