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>
最佳答案
这意味着您忘记了结束 }、)、>
或其语法中使用的任何内容。检查所有 block 和语句,看看是否遗漏了任何结束标记。
如果您将代码复制到 jsbeautifier.org ,单击“美化”并查看所有缩进是否正确。
关于jquery - JavaScript/jQuery |未捕获的语法错误 : Unexpected end of input?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14091304/