📜  jquery 滚动到位置 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:23.553000             🧑  作者: Mango

代码示例3
jQuery(document).ready(function($) {
  $('a[href^="#"]').bind('click.smoothscroll',function (e) {
    e.preventDefault();
    var target = this.hash,
        $target = $(target);

    $('html, body').stop().animate( {
      'scrollTop': $target.offset().top-40
    }, 900, 'swing', function () {
      window.location.hash = target;
    } );
  } );
} );