Search code examples
javascriptjquerycsspositiontext-align

JQuery - Get Absolute x,y position of a centered element


I want to find the left,top positions from an element. However, the parent container of this element has text-align: center; Therefore if there is a few on the bottom row, the first is 0px, rather than say, 450px.


Solution

  • Using offset:

    offset = $( yourselectorhere ).offset()