我试图让我的网站向下滚动,当我点击一个箭头。它可以在这里查看http://www.divisionforty.com/dbarr/jQuery滚动到不工作
但是,由于某种原因,点击上没有任何事情发生。它根本不起作用。我在其他div上尝试过,没有更好的运气。
<script>
$(function() {
$('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>
希望有人可以提供帮助。
感谢,
丹佛
检查'target.length',快速测试在控制台中运行您的代码的几个链接返回'0'。设置一个断点并逐步完成代码 – charlietfl 2014-09-27 15:59:59