jquery实现: 锚点定位添加平滑滚动效果
为需要添加效果的a标签添加class<a class="smooth" href="#content">详情</a>
使用jQuery为a标签添加效果
var $root = $('html, body');
$("a.smooth").click(function() {
$root.animate({
scrollTop: $( $.attr(this, 'href') ).offset().top
}, 500);
return false;
});
撰写评论