Is there a method to determine the element's position in relation to its parent?
Assume we have an image object named 'clone', with a div as its parent:
var parent = clone.parent().offset();
var pos = clone.offset();
If I move the image to the top left corner of the div, the values will be almost the same. But what if I execute this:
var top = pos.top - parent.top;
var left = pos.left - parent.left;
This will provide me with the relative position of the image to its parent, correct? However, storing and displaying these values on different browser sizes may lead to inaccuracies due to changing positions.
Given this explanation, my inquiry is: Is there a technique to prevent this issue and obtain the accurate relative position to its parent directly?
Here is the current code I am utilizing for reference, so feel free to inspect it and suggest ways to improve its functionality!