jquery offset values changes by scrolling the page

前端 未结 6 1690
南旧
南旧 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 17:33

    One other potential cause is if your happens to have CSS that sets overflow-x: hidden; - that completely breaks jQuery's offset() method.

    In that case, $(window).scrollTop() is always 0, so the accepted answer does not work.

提交回复
热议问题