var myObj = document.getElementById("MyObjectsId");
myObj.left = 100;
myObj.top = 200;
you'll notice it doesn't work.. sometimes complaining with an error like: "Declaration Dropped"
In any case, the solution is simple (and a little stupid) add "px" at the end of the number to indicate you meant 100 pixels and not 100 something else.. (em, etc)
so the corrected code should read:
var myObj = document.getElementById("MyObjectsId");
myObj.left = 100 + "px";
myObj.top = 200 + "px";
or:
var myObj = document.getElementById("MyObjectsId");
myObj.left = "100px";
myObj.top = "200px";
that was really frustrating till I figured it out. So, in case you are lost, I hope you find this page, and it helps!
Comments