After dynamically creating an element in jQuery and adding it to the page, I applied a class that sets its position to top:50%
. Everything appeared fine at first glance, with the element positioned correctly at 50%. However, when attempting to retrieve the value of 'top' using .css('top')
, I discovered that it returned an incorrect value of 470 instead of 20. This discrepancy caused errors in the effect that I was trying to achieve, as it relied on obtaining the correct value through JavaScript. Interestingly, this issue does not occur in Firefox; where I can accurately retrieve both the displayed and computed values.
Jsfiddle: http://jsfiddle.net/techsin/dbj2un2e/
d.css( 'top', d.css('top') );
alters the actual position in Chrome. (Uncomment to observe its impact)
To provide further clarification, I have included a screenshot. (View image in new tab for clearer visibility)