Animate jQuery scrolltop

后端 未结 3 1349
我在风中等你
我在风中等你 2021-01-14 00:32

I have a scrollTop function in jQuery but I can\'t animate it. Is it possible?

$(\".loadmore\").click(function() {
  $(this).toggleClass(\"up-arrow\", 1000);         


        
相关标签:
3条回答
  • 2021-01-14 01:06
    $('html, body').animate({ scrollTop: $('.docs').offset().top}, 2000);
    
    0 讨论(0)
  • 2021-01-14 01:18
    $('#ID').click(function(){
    $("html, body").animate({ scrollTop: 0 }, 1000);
    return false;         });
    

    Try this code of Jquery

    0 讨论(0)
  • 2021-01-14 01:23

    You can use animate() for this.

    Example code applied on a div is as follows :

    //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.
    

    Demo can be found here : http://jsfiddle.net/codebombs/GjXzD/

    0 讨论(0)
提交回复
热议问题