This script:
function onscroll(){
document.getElementById(\"divs\").style.top=\"\"+$(\'body\').scrollTop()+\"px\";
}
Fiddle: http://jsf
Try this fiddle, it is working in chrome, ie and the latest version of mozilla : http://jsfiddle.net/Hed2J/3/
I replace $('body').scrollTop()
with $(window).scrollTop()
.
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.