Hi! I am working on a project with several nested DIVs, and I would like to be able to get the top and left coordinates of a DIV when I click on it, relative to the Stage.
I used this code in the On Click action for the DIV:
var objTop = sym.$(e.currentTarget).css("top");
var objLeft = sym.$(e.currentTarget).css("left");
But, since this is a nested DIV, it seems to be giving me the coordinates relative to the parent, not the Stage. Any help you can provide will be greatly appreciated!
Thanks and Happy Thanksgiving!
jquery offset() method should get you what you need.
//////// Start Sample Code ////////
// Example // onClick
// variable reference for the element you want to find the top, left
var p = sym.$("Ellipse");
// variable to hold the offset of the element
var offset = p.offset();
// display the top, left to a Text element or an alert
sym.$("Text").html( "left: " + offset.left + ", top: " + offset.top );
////////// End Sample Code /////////
hope this helps