11. Filling Out the Cases


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

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

11. Filling Out the Cases

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:


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