jQuery に scrollTop 関数がありますが、アニメーション化できません。出来ますか?
$(".loadmore").click(function() {
$(this).toggleClass("up-arrow", 1000);
$(window).scrollTop($('.docs').offset().top, 2000);
});
jQuery に scrollTop 関数がありますが、アニメーション化できません。出来ますか?
$(".loadmore").click(function() {
$(this).toggleClass("up-arrow", 1000);
$(window).scrollTop($('.docs').offset().top, 2000);
});
これに使えますanimate()
。
に適用されるコード例div
は次のとおりです。
//Scroll to bottom
$('div').animate({scrollTop: $('div').get(0).scrollHeight}, 3000);
//$('div').get(0).scrollHeight - will give the full height of div.
//scrollTop - will be used to animate from the current position to page end.
//3000 - will be the duration.
デモはここにあります: http://jsfiddle.net/codebombs/GjXzD/
$('html, body').animate({ scrollTop: $('.docs').offset().top}, 2000);
$('#ID').click(function(){
$("html, body").animate({ scrollTop: 0 }, 1000);
return false; });
このJqueryのコードを試してください