How to scrollTop when html, body is set to height: 100%?

后端 未结 6 1206
别跟我提以往
别跟我提以往 2021-01-04 03:26

The following won\'t work unless I remove height: 100% from body and html. However, i need that style as I am using it for other elements on the page.

<

6条回答
  •  清酒与你
    2021-01-04 04:05

    This worked for me:

    $("#scrollTop").on("click",function(e){
      $('html,body').animate({scrollTop: 0}, 'slow');
    });
    

    http://jsfiddle.net/fvuy6/41/

提交回复
热议问题