gpt4 book ai didi

javascript - 为什么我的 jQuery "complete"回调在 Chrome 和 Safari 中中断但在 FF 中工作正常?

转载 作者:行者123 更新时间:2023-11-30 10:55:17 25 4
gpt4 key购买 nike

我对这段 jQuery 代码有一些疑问。我是新来的,但它在 FF 中工作,但在 Chrome 和 Safari 中中断。以任何方式感谢您的建议。

 $('#level1nav ul li a:last').click(function () {

$(lastBlock).animate({height:"400px"}, {queue:false, duration:500,
complete: function()
$(line).animate({width:"0px"}, {queue:false, duration:500,
complete: function() {window.location="?info"}
})
});
return false;
});

最佳答案

这是你的问题:

complete: function() 
$(line).animate({width:"0px"}, {queue:false, duration:500,
complete: function() {window.location="?info"}
})

您缺少外部函数体的左花括号和右花括号。它应该看起来像这样:

complete: function()

{

$(line).animate({width:"0px"}, {queue:false, duration:500,
complete: function() {window.location="?info"}
})

}

这在 Firefox 中有效,因为 JavaScript 1.8 introduced在有限的情况下不需要大括号的函数的“速记”:

Expression closures

This addition is nothing more than a shorthand for writing simple functions, giving the language something similar to a typical Lambda notation.

...

This syntax allows you to leave off the braces and 'return' statement - making them implicit. There is no added benefit to writing code in this manner, other than having it be syntactically shorter.

关于javascript - 为什么我的 jQuery "complete"回调在 Chrome 和 Safari 中中断但在 FF 中工作正常?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2142755/

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