Mario isn't moving - Filling out the cases


#1

My code isn't working. I tried on Safari and Chrome. I even copy/pasted the exact code that is supposed to work (found on forum). Below is my code. What am i missing??
$(document).ready(function() {
$(document).keydown(function(key) {
switch(parseInt(key.which,10)) {
// Left arrow key pressed
case 37:
$('img').animate({left: "-=10px"}, 'fast');
break;
// Up Arrow Pressed
case 38:
$('img').animate({up: "-=10px"}, 'fast');
break;
// Right Arrow Pressed
case 39:
$('img').animate({right: "+=10px"}, 'fast');
break;
// Down Arrow Pressed
case 40:
$('img').animate({down: "+=10px"}, 'fast');
break;
}
});
});


#2

read about properties that can be animated.
in case 40 use property top instead down.


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.