![](/img/trans.png)
[英]How to check iframe html file scroll is reached to bottom or not using jquery
[英]How to Scroll Bottom using Jquery?
實際上我正在使用以下代碼在頂部滾動
var container = $('#items_suggession_right'), scrollTo = $(".selected");
container.animate({scrollTop: scrollTo.offset().top - container.offset().top +
container.scrollTop()}, 0);
但我不能滾動設置在底部。 請幫助我使用jQuery設置底部滾動
您可以使用
var time = 0; // in milliseconds
$("html, body").animate({ scrollTop: $(document).height() }, time);.
您可以增加時間值以提供更平滑,更生動的滾動到底部。
輸入以下代碼以滾動到頁面底部。
container.animate({ scrollTop: $(document).height() }, 0);
$(document).on("click","#bottom",function() {
var window_height = $(window).height();
var document_height = $(document).height();
$('html,body').animate({ scrollTop: window_height + document_height },1000);
});
希望能幫助到你!
$(document).ready(function() {
$('#buttonID').click(function(){
$('html, body').animate({scrollTop:$(document).height()}, 'slow');
return false;
});
});
只需使用此代碼部分。
您可以使用 :
$('html').animate({ scrollTop: $(document).height() }, 1000);
$(document).ready(function() { $('html,body').animate({ scrollTop: $('.testwrap').height() }, 800); });
.testwrap{ width: 500px; height: 1000px; border: 2px dotted #c00; }
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"> </script> </head> <body> <div class="testwrap"></div> </body> </html>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.