无用的 setTimeout 调用(参数周围缺少引号?)
我在 jQuery delay
中将这段代码
$element.parent().children().last().hide().show('slide', {direction : 'left'}, 700, function () {
$element.delay(2000, function() {
$element.parent().children().last().hide('slide', {direction: 'left'}, 700);
reload_table(question_number);
//delay ends here
});
});
声明为:
jQuery.fn.delay = function(time,func){
return this.each(function(){
setTimeout(func,time);
});
};
现在我收到错误:
无用的 setTimeout 调用(参数周围缺少引号?)
FF3.x,Firefox 6+ 可以。对此有什么想法吗?为什么会发生这种情况?
I have this sniplet of code in jQuery
$element.parent().children().last().hide().show('slide', {direction : 'left'}, 700, function () {
$element.delay(2000, function() {
$element.parent().children().last().hide('slide', {direction: 'left'}, 700);
reload_table(question_number);
//delay ends here
});
});
delay
is declared as:
jQuery.fn.delay = function(time,func){
return this.each(function(){
setTimeout(func,time);
});
};
Now I get the error:
useless setTimeout call (missing quotes around argument?)
FF3.x, Firefox 6+ is ok. Any ideas on that? Why could this be happening?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
,我遇到了同样的错误
当我写而不是时
I got same error when I wrote
instead of
我同意 wsbaser 的观点。我有另一个需要将信息传递给函数的实例,为了简单起见,使用了:
参数必须是一个函数,而不是被调用的函数。 Firefox 发现了这个错误,chrome 放过了它。
I agree with wsbaser. I had the additional instance of needed to pass information to the function, and for simplicity used:
The argument needs to be a function and not a function being called. Firefox caught this error, chrome let it go.
如果有人偶然发现这个问题并正在寻找可能的答案,仅供参考。我得到了与最初的海报完全相同的错误消息,因为我混淆了 setTimeout 参数顺序。
这:
...给了我错误消息。我将功能更改为:
我的问题解决了。
Just for reference if someone stumbles upon this question and is looking for a possible answer. I got the exact same error message as the initial poster because I was mixing up the
setTimeout
arguments order.This:
... gave me the error message. I changed the function to this:
And my problem was solved.
已经存在一个 jQuery 方法 delay 并且它需要一个字符串(queueName)而不是一个函数作为参数。
为您的延迟方法选择另一个名称以避免冲突。
There already exists a jQuery-method delay and it expects a string(queueName) and not a function as parameter.
Choose another name for your delay-method to avoid conflicts.
问题出在 Firefox 3 中。它没有正确处理某些元素=>元素在树中被完全省略并被忽略 ->因此我原来的问题
The problem was in Firefox 3. It is not handling some elements properly => Element is completely omitted in the tree and ignored -> hence my original problem