I've been trying to get the onkeypress
function to manipulate absolute positioning. My code works once just fine, and then the element never moves again.
Any help would be much appreciated.
JavaScript:
var div = document.getElementById('div');
window.onkeydown = function (e) {
switch (e.which) {
case 37:
div.style.left = (div.style.left - 10) + 'px';
break;
}
}
Markup:
<html><body><div id='div'></div></body></html>