11. Filling Out the Cases


#1

I have almost the same problem. When I press the down key it wont work. The up,right,left keys work. Its just the down key that wont respond. Here is my code.

$(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({top: "-=10px"}, 'fast');
break;
// Right Arrow Pressed
case 39:
$('img').animate({left: "+=10px"}, 'fast');
break;
// Down Arrow Pressed
case 40:
$('img').animate({top: "+=10x"}, 'fast');
break;
}
});
});

Is this an issue, or no. Because I NEED HELP.


11. Filling Out the Cases
#2

You have written $('img').animate({top: "+=10x"}, 'fast'); instead of $('img').animate({top: "+=10px"}, 'fast');, so your unit is wrong. :slight_smile: Fix it and it should be good. :slight_smile:


#3

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