Jquery offset values changes by scrolling the page


var offset = $(selector).offset();

The values of offset variable changes if we scroll the page up and down, i want the exact and fixed offset values while keeping the position of the "selector" default(static).How can i do this?

Best Solution

You could always calculate the offset, factoring in the scroll position:

var offset_t = $(selector).offset().top - $(window).scrollTop();
var offset_l = $(selector).offset().left - $(window).scrollLeft();