Javascript – How to find the absolute position of an element using jQuery

javascriptjquery

Is there a way of finding the absolute position of an element, i.e. relative to the start of the window, using jQuery?

Best Answer

.offset() will return the offset position of an element as a simple object, eg:

var position = $(element).offset(); // position = { left: 42, top: 567 }

You can use this return value to position other elements at the same spot:

$(anotherElement).css(position)