本文实例讲述了jQuery实现平滑滚动到指定锚点的方法。
html代码
<a href="#section_07" class="topLink"></a>
<section class="section_07" id="section_07">
通过 a href使页面跳转至id为section_07的页面。
js代码
//锚点平滑滚动
$("a.topLink").click(function() {
$("html, body").animate({
scrollTop: $($(this).attr("href")).offset().top + "px"
}, {
duration: 600,
easing: "linear"
});
return false;
});
我是新手,有不足的问题希望提出。
希望本文所述对大家的jQuery程序设计有所帮助。