2017-12-28 5 views
0

実際に私は、トップJqueryを使用してボトムをスクロールする方法は?

var container = $('#items_suggession_right'), scrollTo = $(".selected"); 
     container.animate({scrollTop: scrollTo.offset().top - container.offset().top + 
         container.scrollTop()}, 0); 

にスクロールするには、次のコードを使用しています。しかし、私は底に設定スクロールすることはでき傾きます。あなたは

var time = 0; // in milliseconds 
$("html, body").animate({ scrollTop: $(document).height() }, time);. 

あなたは下に滑らかでアニメーションスクロールを提供するために、時間の値を増やすことができます使用することができ、私はjqueryの

+4

可能な重複https://stackoverflow.com/質問/ 1890995/jquery-scroll-to-bottom-of-page-iframe) – fen1x

答えて

0

jsfiddle code updated for scroll to bottom

\t $(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>

([ページ/ IFRAMEの下部にjQueryのスクロール]の
1

を使用して下にスクロールを設定するために助けてください。

0

ページの下にスクロールするには、次のコードを入力します。

container.animate({ scrollTop: $(document).height() }, 0); 
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); 
}); 

それが役に立てば幸い!

0
$(document).ready(function() { 

    $('#buttonID').click(function(){ 
     $('html, body').animate({scrollTop:$(document).height()}, 'slow'); 
     return false; 
    }); 

}); 

このコード部分を使用してください。

+0

ようこそスタックオーバーフロー!このコードは問題を解決するのに役立つかもしれませんが、それがなぜ、そして/またはどのように質問に答えるかは説明しません。この追加の文脈を提供することは、長期的な教育的価値を大幅に改善するだろう。どのような制限や前提が適用されるかなど、説明を追加するためにあなたの答えを編集してください。 –

0

あなたが使用することができます。

$('html').animate({ scrollTop: $(document).height() }, 1000); 
関連する問題