JQuery scroll to top of Bootstrap Modal

前端 未结 7 1286
小蘑菇
小蘑菇 2020-12-23 19:37

I\'m currently using the bootstrap modal plugin to display long legal messages on a website I\'m designing, but the problem is that if you open one modal after the other, th

相关标签:
7条回答
  • 2020-12-23 20:12

    In Bootstrap 4, the following works for me:

    $('.modal-body').scrollTop(0);
    

    You need to scrollTop on the modal-body because the parent elements (modal, modal-dialog, modal-content) are containers and do not scroll with the user.

    However, if you prefer a less jerky movement, try the animation route:

    $('.modal-body').animate({scrollTop: 0},400);
    
    0 讨论(0)
提交回复
热议问题