how to find the vertical distance from top in px of an element using jQuery

前端 未结 4 1133
时光取名叫无心
时光取名叫无心 2021-01-30 09:52

How do I find the vertical distance from the top of the page to where the element exist in the DOM using javascript/jQuery?

I\'ve something like



        
4条回答
  •  不要未来只要你来
    2021-01-30 10:28

    As far as i know .offset() get the distance between the current scroll position and the top of the document.

    You need to use this: $("li.test").position().top

提交回复
热议问题