Javascript Jquery延迟不工作
有人能告诉我为什么在我的图像显示后我的函数没有执行吗Javascript Jquery延迟不工作,javascript,jquery,Javascript,Jquery,有人能告诉我为什么在我的图像显示后我的函数没有执行吗 $("#screen").css("background-image", "url('screens/animated/077.gif')").delay(5000).queue(function() { $("#screen").css("background-image", "url('screens/animated/078.gif')").delay(5000).queue(function() {
$("#screen").css("background-image", "url('screens/animated/077.gif')").delay(5000).queue(function() {
$("#screen").css("background-image", "url('screens/animated/078.gif')").delay(5000).queue(function() {
buttonClick(16);
});
});
不知道为什么它不会叫我的按钮点击(16);函数。因为您没有排队
$("#screen").css("background-image", "url('screens/animated/077.gif')").delay(5000).queue(function () {
$(this).css("background-image", "url('screens/animated/078.gif')").delay(5000).queue(function () {
$(this).dequeue();
buttonClick(16);
}).dequeue();
});
因为你没有排队
$("#screen").css("background-image", "url('screens/animated/077.gif')").delay(5000).queue(function () {
$(this).css("background-image", "url('screens/animated/078.gif')").delay(5000).queue(function () {
$(this).dequeue();
buttonClick(16);
}).dequeue();
});
queue函数接收一个参数,您应该在下一个函数运行时调用该参数。 例如:
queue函数接收一个参数,您应该在下一个函数运行时调用该参数。 例如:
你可以用动画代替,伙计?animate()您可以将时间传递给,并且它还有一个回调函数,因此在第一个动画完成后,您可以运行更多代码,即
$(this).animate(function(){
//Do animation
},1000,function(){
//Animation is complete, do something else like the next animation
$(this).animate(function(){
//Another animation to run once the first is complete
});
});
你可以用动画代替,伙计?animate()您可以将时间传递给,并且它还有一个回调函数,因此在第一个动画完成后,您可以运行更多代码,即
$(this).animate(function(){
//Do animation
},1000,function(){
//Animation is complete, do something else like the next animation
$(this).animate(function(){
//Another animation to run once the first is complete
});
});
它有定义吗?您的控制台中是否有任何错误?您是否尝试过一些简单的调试,例如在延迟函数之外调用buttonClick?是否定义了它?您的控制台中是否有任何错误?您是否尝试过一些简单的调试,例如在延迟函数之外调用按钮单击?