Javascript/jQuery | 未捕获的 SyntaxError:意外的输入结束?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14091304/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 13:15:39  来源:igfitidea点击:

Javascript/jQuery | Uncaught SyntaxError: Unexpected end of input?

jquery

提问by Necro.

jQuery noob checking in here. What is wrong with my syntax? I get Unexpected End of Input in Chrome console.

jQuery 菜鸟在这里检查。我的语法有什么问题?我在 Chrome 控制台中收到意外的输入结束。

 <script>
$('a[href*=#]:not([href=#])').click(function() {
  if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') 
     || location.hostname == this.hostname) {

     var target = $(this.hash);
     target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
        if (target.length) {
          $('html,body').animate({
              scrollTop: target.offset().top
         }, 1000);
         return false;
        }
     }
 });
</script>

回答by Techie

It means you've forgotten a closing }, ), >, or whatever is used in its syntax. Check all of your blocks and statements to see if you've left out any closing mark.

这意味着你忘记了一个结束语}, ), >,或者它的语法中使用的任何东西。检查您的所有块和语句,看看您是否遗漏了任何结束标记。

if you copy your code into jsbeautifier.org, click on "Beautify" and see if all of the indentations are correct.

如果您将代码复制到jsbeautifier.org,请单击“美化”并查看所有缩进是否正确。