jQuery noob在这里检查.我的语法有什么问题?我在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>
Run Code Online (Sandbox Code Playgroud)
这意味着你已经忘记了结束语}, ), >,或者语法中使用的任何内容.检查所有块和语句,看看是否遗漏了任何结束标记.
如果您将代码复制到jsbeautifier.org,请单击"Beautify"并查看所有缩进是否正确.