无用的 setTimeout 调用(参数周围缺少引号?)

发布于 2024-12-17 08:34:15 字数 665 浏览 8 评论 0原文

我在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

椒妓 2024-12-24 08:34:15

,我遇到了同样的错误

setTimeout(updateStatus(), 5000);

当我写而不是时

setTimeout(updateStatus, 5000);

I got same error when I wrote

setTimeout(updateStatus(), 5000);

instead of

setTimeout(updateStatus, 5000);
寂寞清仓 2024-12-24 08:34:15

我同意 wsbaser 的观点。我有另一个需要将信息传递给函数的实例,为了简单起见,使用了:

setTimeout(function(){ updateStatus(myData) } , 5000);

参数必须是一个函数,而不是被调用的函数。 Firefox 发现了这个错误,chrome 放过了它。

I agree with wsbaser. I had the additional instance of needed to pass information to the function, and for simplicity used:

setTimeout(function(){ updateStatus(myData) } , 5000);

The argument needs to be a function and not a function being called. Firefox caught this error, chrome let it go.

从﹋此江山别 2024-12-24 08:34:15

如果有人偶然发现这个问题并正在寻找可能的答案,仅供参考。我得到了与最初的海报完全相同的错误消息,因为我混淆了 setTimeout 参数顺序。

这:

setTimeout(25, function(){
    spotlight.intro.find('#intro').ellipsis();  
});

...给了我错误消息。我将功能更改为:

setTimeout(function(){
    spotlight.intro.find('#intro').ellipsis();
}, 25);

我的问题解决了。

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:

setTimeout(25, function(){
    spotlight.intro.find('#intro').ellipsis();  
});

... gave me the error message. I changed the function to this:

setTimeout(function(){
    spotlight.intro.find('#intro').ellipsis();
}, 25);

And my problem was solved.

第七度阳光i 2024-12-24 08:34:15

已经存在一个 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.

著墨染雨君画夕 2024-12-24 08:34:15

问题出在 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文