SyntaxError: missing ] after element list [object Object]

前端 未结 3 529
自闭症患者
自闭症患者 2021-01-22 14:42

I got this error in firebug :

     SyntaxError: missing ] after element list

    [object Object]

for the following javascript piece of code :

相关标签:
3条回答
  • 2021-01-22 14:56

    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.

    0 讨论(0)
  • 2021-01-22 15:00

    setTimeout 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 combination of setTimeouts and the loop. I would expect some wild oddities to come 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...

    0 讨论(0)
  • 2021-01-22 15:04

    You can also try this , this also works

    setTimeout(" $('#uploaded-holder').hide() ", i * 300 );

    Add the first parameter within double quotes.

    0 讨论(0)
提交回复
热议问题