4 回答

TA贡献1719条经验 获得超6个赞
试试这个代码:
$('.Classname').click(function(){
$("html, body").animate({ scrollTop: 0 }, 600);
return false;
});

TA贡献1712条经验 获得超3个赞
用这个:
$('a[href^="#"]').on('click', function(event) {
var target = $( $(this).attr('href') );
if( target.length ) {
event.preventDefault();
$('html, body').animate({
scrollTop: target.offset().top
}, 500);
}
});

TA贡献1865条经验 获得超7个赞
尝试以下方法:
var body = $("body, html");
var top = body.scrollTop() // Get position of the body
if(top!=0)
{
body.animate({scrollTop :0}, 500,function(){
//DO SOMETHING AFTER SCROLL ANIMATION COMPLETED
alert('Hello');
});
}
- 4 回答
- 0 关注
- 734 浏览
添加回答
举报