Skip to content

Instantly share code, notes, and snippets.

@libo1106
Created February 18, 2013 03:40
Show Gist options
  • Save libo1106/4974975 to your computer and use it in GitHub Desktop.
Save libo1106/4974975 to your computer and use it in GitHub Desktop.
锚点平滑滚动
$('a').click(function(){
var href = $(this).attr("href");
var pos = $(href).offset().top;
$("html,body").animate({scrollTop: pos}, 1000);
return false;
});
// 参考网址
// http://www.zhangxinxu.com/wordpress/2010/07/锚点跳转及jquery下相关操作与插件/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment