When trying to retrieve the position (relative to non-static parent) of an element, if later in the code the position (css style) is set to anything other than the default, static, the values returned (before this css property is supposed to have been set) are wrong (the top left of their static parent). Help?
Makes sense:
var top = $(this).position().top;
var left = $(this).position().left;
console.log(left);
console.log(top);
Console
- main.js:660
- main.js:0
- main.js:800
- main.js:0
- main.js:660
- main.js:100
- main.js:800
- main.js:100
- ...
Doesn't make sense?:
var top = $(this).position().top;
var left = $(this).position().left;
console.log(left);
console.log(top);
$(this).css({
'position': 'absolute', // or relative
});
Console
- main.js:660
- main.js:0
- main.js:660
- main.js:0
- main.js:660
- main.js:0
- ...