Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Get Element's Offsets

DZone's Guide to

Get Element's Offsets

·
Free Resource
Retrieves the element's offsets


//+ Jonas Raoni Soares Silva
//@ http://jsfromhell.com
function getOffset(o){
	for(var r = {x: o.offsetLeft, y: o.offsetTop, h: o.offsetHeight, w: o.offsetWidth}; o = o.offsetParent; r.x += o.offsetLeft, r.y += o.offsetTop);
	return r;
}
Topics:

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}