jquery offset values changes by scrolling the page

前端 未结 6 1674
南旧
南旧 2020-12-15 16:55
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 value

6条回答
  •  时光说笑
    2020-12-15 18:00

    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();
    

提交回复
热议问题