I\'m a beginner in Javascript, and trying to make a simple script that pushes a box using the mouse pointer. But unfortunately it isn\'t working for some reason, i hope you guys
Lastly you are better off adding stuff onload instead of having the script live in the body
Here is a script that lives in the head of the page, the rest of the issues are already solved by other ppl here
var pushBox = function(e){
if(e.pageX >= box.offsetLeft){
box.style.left = (parseInt(box.style.left,10) + 1) + "px";
}
},box;
window.onload=function() {
box = document.getElementById("box");
document.addEventListener("mousemove" , pushBox);
}