gpt4 book ai didi

jQuery : How to load a function after some interval or after end of another function or event

转载 作者:行者123 更新时间:2023-12-01 05:09:31 24 4
gpt4 key购买 nike

我需要在定时延迟后或在上一个动画完成结束时运行函数“setNotifications()”(“#topannounce”动画)。但是 jQuery 在动画之后没有运行“setNotifications()” 。我应该怎么办?或者有更好的方法来运行该函数吗?Plz hlp.Thanx。

这是我的 jQuery。

$('a#resetbtn').bind('click', function(){
//setNotifications();
$.cookie('notificationBar', 'open');
//$('#topannounce').animate({opacity: 1.0}, 3000).fadeIn('slow');
$('#topannounce').fadeIn('slow');
setNotifications();

});

function setNotifications() {
alert("load:setNotifications...");
}

最佳答案

实际上,您的代码中没有真正的错误,它应该可以工作,并且您应该看到消息框警报,但这应该在您单击 anchor 时立即发生。

如果您希望警报在淡入之后出现,请使用回调,例如:

$('a#resetbtn').bind('click', function(){
//setNotifications();
$.cookie('notificationBar', 'open');
//$('#topannounce').animate({opacity: 1.0}, 3000).fadeIn('slow');
$('#topannounce').fadeIn('slow', setNotifications);
});

function setNotifications() {
alert("load:setNotifications...");
}

关于jQuery : How to load a function after some interval or after end of another function or event,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3059314/

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