I am calling .css()
function at page load with the following code:
$(function(){
var positionLeft = parseInt($(".wrapper").css("margin-left"))-50;
if (isNaN(positionLeft)){
console.log(positionLeft);
}
$("#full-wrapper").css("margin-left",(positionLeft+"px").toString());
});
For some reason, the positionLeft is always NaN
. If I use setInterval(fn,1), and ask for a positionLeft just 1ms later, the positionLeft is as expected. What is going on here?