11/12. Filling out the Cases


I have passed this lesson, but my code only works when you press the left arrow. it does not work for the other directions. Someone please tell me why. 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({up: "+=10px"}, 'fast');
			// Right Arrow Pressed
			case 39:
				$('img').animate({right: "+=10px"}, 'fast');
			// Down Arrow Pressed
			case 40:
				$('img').animate({down: "-=10px"}, 'fast');

Thank you :grin:


Sorry I changed my code now. Only the right arrow does not work.

11/12 | Mario runs, but doesn't work

There are no directions in CSS, and .animate() only recognizes the left and top boundaries (reference axes).


top: /* plus or minus */
left: /* plus or minus */


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