jQuery scrolltop firefox not working

前端 未结 2 1135
鱼传尺愫
鱼传尺愫 2020-11-27 08:09

This script:

function onscroll(){
    document.getElementById(\"divs\").style.top=\"\"+$(\'body\').scrollTop()+\"px\";
}

Fiddle: http://jsf

2条回答
  •  囚心锁ツ
    2020-11-27 08:55

    A little off-topic, but if you want to animate using scrolltop, you must do

    $('html,body').animate({scrollTop:0}, 'slow');
    

    Note that we target both html and body because html will make scroll in Firefox works and body for other browsers.

提交回复
热议问题