[removed] SyntaxError: missing ) after argument list

前端 未结 2 1371
野的像风
野的像风 2020-12-05 09:37

I am getting the error:

SyntaxError: missing ) after argument list

With this javascript:

var nav = document.getE         


        
2条回答
  •  独厮守ぢ
    2020-12-05 10:03

    You got an extra } to many as seen below:

    var nav = document.getElementsByClassName('nav-coll');
    for (var i = 0; i < button.length; i++) {
        nav[i].addEventListener('click',function(){
                console.log('haha');
            } // <-- REMOVE THIS :)
        }, false);
    };
    

    A very good tool for those things is jsFiddle. I have created a fiddle with your invalid code and when clicking the TidyUp button it formats your code which makes it clearer if there are any possible mistakes with missing braces.


    DEMO - Your code in a fiddle, have a play :)


提交回复
热议问题