11/12 code can work and animate can move, still error,why?


#1


https://www.codecademy.com/courses/web-beginner-en-JwhI1/2/3?curriculum_id=50a3fad8c7a770b5fd0007a1#


my code can work, and the animate can move
but it still wrong, the wrong message is
"Oops, try again. Make sure to press 'left', 'up', 'right', or 'down' to make your character move!"


$(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: "+=10px"}, 'fast');
				break;
		}
	});
});


#2

Your code works, read the error message. You need to move the character after you click save & submit, move the character, then click back to editor.

I hope I helped!


#3

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