views:

20

answers:

2

How do you bind it so that when a user scrolls, I can know the "offset" from the top, in pixels?

A: 
var p = $("p:last");
var offset = p.offset();
p.html( "left: " + offset.left + ", top: " + offset.top );
powtac
No, this is not what I mean. I'd like to know...for example...if a person scrolls down 100 pixels, I'd like to know that it's 100 pixels.
TIMEX
Ok, check the answer of David!
powtac
+2  A: 
$(document).scroll(function(e) {
    var offset = $(e.target).scrollTop();
});
David