我試圖讓我的網站向下滾動,當我點擊一個箭頭。它可以在這裏查看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