admin管理员组文章数量:1287629
I got this error in firebug :
SyntaxError: missing ] after element list
[object Object]
for the following javascript piece of code :
for ( var i = 0; i < 4; i++ ) {
setTimeout( function(){
closeBtn( i,'.lt400' );
// the error exactly happened in next line:
setTimeout($('#uploaded-holder').hide(), i * 300 );
}, i * 300 );
}
I don't know how a ] can be missing there.. by the way, in chrome i got this error :
Uncaught SyntaxError: Unexpected identifier
I got this error in firebug :
SyntaxError: missing ] after element list
[object Object]
for the following javascript piece of code :
for ( var i = 0; i < 4; i++ ) {
setTimeout( function(){
closeBtn( i,'.lt400' );
// the error exactly happened in next line:
setTimeout($('#uploaded-holder').hide(), i * 300 );
}, i * 300 );
}
I don't know how a ] can be missing there.. by the way, in chrome i got this error :
Uncaught SyntaxError: Unexpected identifier
Share
Improve this question
edited Nov 26, 2013 at 13:46
JAAulde
19.6k5 gold badges56 silver badges64 bronze badges
asked Nov 26, 2013 at 13:44
BardelmanBardelman
2,2989 gold badges45 silver badges75 bronze badges
3
-
1
better
setTimeout( function () { $('#uploaded-holder').hide() }, i * 300 );
– Praveen Commented Nov 26, 2013 at 13:45 - yeah , i did it and it's ok , thanks :) – Bardelman Commented Nov 26, 2013 at 13:47
- Glad to hear, it helped :) – Praveen Commented Nov 26, 2013 at 13:50
3 Answers
Reset to default 7setTimeout
expects a function or a string of code as the first parameter. You are passing the result of the evaluation of this expression:
$('#uploaded-holder').hide()
This expression returns neither a string, nor a function. It returns a jQuery collection.
You want:
setTimeout(function () {
$('#uploaded-holder').hide();
}, i * 300 );
You have an odd set of code there, though, given the bination of setTimeouts and the loop. I would expect some wild oddities to e from it once this error is resolved. For example, i
is not going to be what you expect in the execution of many of those internal functions...
You may try to use this:-
setTimeout( function ()
{ $('#uploaded-holder').hide() }, i * 300 );
instead of
setTimeout($('#uploaded-holder').hide(), i * 300 );
as setTimeout expects a string or a function as first parameter.
You can also try this , this also works
setTimeout(" $('#uploaded-holder').hide() ", i * 300 );
Add the first parameter within double quotes.
本文标签: javascriptSyntaxError missingafter element list object ObjectStack Overflow
版权声明:本文标题:javascript - SyntaxError: missing ] after element list [object Object] - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741257206a2366908.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论