参数列表后面的JavaScript:SyntaxError:missing) [英] JavaScript: SyntaxError: missing ) after argument list

查看:90
本文介绍了参数列表后面的JavaScript:SyntaxError:missing)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到错误:

SyntaxError: missing ) after argument list

使用此javascript:

With this javascript:

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

这个错误是什么意思?

推荐答案

您的函数中还有一个额外的结算}

You have an extra closing } in your function.

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

你真的应该使用像 JSHint JSLint 以帮助查找这些内容。这些工具与许多编辑器和IDE集成,或者您只需将代码片段粘贴到上述网站中并要求进行分析。

You really should be using something like JSHint or JSLint to help find these things. These tools integrate with many editors and IDEs, or you can just paste a code fragment into the above web sites and ask for an analysis.

这篇关于参数列表后面的JavaScript:SyntaxError:missing)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆