Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I find the position in the page of an element using jQuery?

I'm aware of the position method, but that retrieves the position relative to the offset parent. Do I just throw in a loop to transverse up the document nodes?

I guess that I'm surprised that it isn't part of the core, and I'm wondering if it's tucked away somewhere that I don't know about.

like image 267
Keith Bentrup Avatar asked Feb 28 '23 17:02

Keith Bentrup


1 Answers

jQuery(elem).offset();

See http://docs.jquery.com/CSS/offset for a summary

like image 71
joshcomley Avatar answered Mar 03 '23 09:03

joshcomley