Skip to content

Instantly share code, notes, and snippets.

@kanduvisla
Created May 3, 2012 14:32
Show Gist options
  • Save kanduvisla/2586006 to your computer and use it in GitHub Desktop.
Save kanduvisla/2586006 to your computer and use it in GitHub Desktop.
Set the X and Y property of an element
/**
* Set the X and Y property of the element
*
* @param elem
*/
function setXY(elem)
{
elem.x = elem.offsetLeft;
elem.y = elem.offsetTop;
var parent = elem.offsetParent;
while(parent != undefined)
{
elem.x += parent.offsetLeft;
elem.y += parent.offsetTop;
parent = parent.offsetParent;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment