1
我一直在嘗試實施Ariel Flesler的ScrollTo插件,但我似乎想出如何啓動它。這是他的網站:無法讓Ariel Flesler的ScrollTo工作
我想這樣做是有一個靜態的導航,並且當用戶點擊一個鏈接導航,特定專區內的內容滾動。我對jQuery有一個很好的理解,看起來這個插件應該很容易使用,但是這些文檔很適合演示如何實際使用它。
我一直在嘗試實施Ariel Flesler的ScrollTo插件,但我似乎想出如何啓動它。這是他的網站:無法讓Ariel Flesler的ScrollTo工作
我想這樣做是有一個靜態的導航,並且當用戶點擊一個鏈接導航,特定專區內的內容滾動。我對jQuery有一個很好的理解,看起來這個插件應該很容易使用,但是這些文檔很適合演示如何實際使用它。
彼得是正確的,你可以這樣做:
$(document).ready(function(){
$('a[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) {
var targetOffset = $target.offset().top;
$('html,body')
.animate({scrollTop: targetOffset}, 1000);
return false;
}
}
});
});
聽起來像它會是簡單的使用jQuery'.animate()'不是整個插件你的描述。 – 2010-10-20 17:46:48