jQuery - ScrollTop without animation

前端 未结 7 2102
鱼传尺愫
鱼传尺愫 2020-12-30 23:20

How can I use the scrolltop without an animation

This code works:

var offTop = $(\'#box\').offset().top;
offTop  = offTop-43;
$(\'#mainCt\').animate(         


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

    Why not use it with less duration. I fiddled it and it had no animation. SInce there will be no time to see the animation, there will be no animation at all.

    var offTop = $('#box').offset().top;
    offTop  = offTop-43;
    $('#mainCt').animate({scrollTop: '+=' + offTop + 'px'}, 50); //50 added here as duartion
    
    0 讨论(0)
提交回复
热议问题