It is possible to move an element using :
var element = document.getElementById("animate"); element.style.top = 10 + "px"; element.style.left = 10 + "px";
So why is it not possible to read the position using :
var element = document.getElementById("animate"); var vertical = element.style.top; var horizontal = element.style.left; document.getElementById("write0").innerHTML = "vertical = " + vertical + " horizontal = " + horizontal;
The answer to that snippet is "vertical = horizontal = "
How are we supposed to read it? I tried adding .toString() but the result was the same.