参数列表后面的SyntaxError:missing)

kar*_*hik 27 javascript jquery

我收到语法错误:

SyntaxError: missing ) after argument list
Run Code Online (Sandbox Code Playgroud)

从这个jQuery代码:

$('#contentData').append(
  "<div class='media'><div class='media-body'><h4 class='media-heading'>" + 
  v.Name + "</h4><p>" + v.Description + "</p><a class='btn' href='" + 
  type + "'  onclick="(canLaunch('" + v.LibraryItemId + " '))">
  View &raquo;
  </a></div></div>")
Run Code Online (Sandbox Code Playgroud)

什么样的错误产生这个Javascript语法错误?

Aru*_*hny 28

"在onclick处理程序中没有转义,用它来逃避它\"

$('#contentData').append("<div class='media'><div class='media-body'><h4 class='media-heading'>" + v.Name + "</h4><p>" + v.Description + "</p><a class='btn' href='" + type + "'  onclick=\"(canLaunch('" + v.LibraryItemId + " '))\">View &raquo;</a></div></div>")
Run Code Online (Sandbox Code Playgroud)


Eri*_*ski 9

如何重现此错误:

SyntaxError: missing ) after argument list
Run Code Online (Sandbox Code Playgroud)

此代码产生错误:

<html>
<body>
<script type="text/javascript" src="jquery-2.1.0.min.js"></script>
<script type="text/javascript">
  $(document).ready(function(){

  }
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

如果你运行它并查看firebug中的错误输出,则会出现此错误.传入"就绪"的空函数未关闭.修复如下:

<html>
<body>
<script type="text/javascript" src="jquery-2.1.0.min.js"></script>
<script type="text/javascript">
  $(document).ready(function(){

  });      //<-- notice the right parenthesis and semicolon
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

然后正确解释Javascript.


Cha*_*ari 5

对我来说,一旦功能拼写错误

例如代替

$(document).ready(function(){

});
Run Code Online (Sandbox Code Playgroud)

我写

$(document).ready(funciton(){

});
Run Code Online (Sandbox Code Playgroud)

所以也要检查一下