jQuery实现平滑滚动到指定锚点的方法

本文实例讲述了jQuery实现平滑滚动到指定锚点的方法。
html代码html

<a href="#section_07" class="topLink"></a>
            
<section class="section_07" id="section_07">

经过 a href使页面跳转至id为section_07的页面。
js代码this

//锚点平滑滚动
    $("a.topLink").click(function() {
    $("html, body").animate({
      scrollTop: $($(this).attr("href")).offset().top + "px"
    }, {
      duration: 600,
      easing: "linear"
    });
    return false;
    });

我是新手,有不足的问题但愿提出。
但愿本文所述对你们的jQuery程序设计有所帮助。设计

相关文章
相关标签/搜索