4 回答

TA貢獻(xiàn)1719條經(jīng)驗(yàn) 獲得超6個(gè)贊
試試這個(gè)代碼:
$('.Classname').click(function(){
$("html, body").animate({ scrollTop: 0 }, 600);
return false;
});

TA貢獻(xiàn)1712條經(jīng)驗(yàn) 獲得超3個(gè)贊
用這個(gè):
$('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貢獻(xiàn)1865條經(jīng)驗(yàn) 獲得超7個(gè)贊
嘗試以下方法:
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 關(guān)注
- 715 瀏覽
添加回答
舉報(bào)