11/12 Please help me


#1

Can anyone tell what am I doing wrong here?

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

#2

Hi M,

Please state the error message you're getting and post a link to the exercise.
Fixing your problem, I think you just need to click on Mario and press an arrow key after submitting your code, before returning to the editor :slightly_smiling:


#3

Thank you, it worked :smiley:

The error Message was: "Please follow the instruction from the full preview page to test your code".


#4

So, mine is the same error, but the image won't respond.

$(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:
// Put our code here
break;
// Right Arrow Pressed
case 39:
// Put our code here
break;
// Down Arrow Pressed
case 40:
// Put our code here
break;
}
});
});


#5

@chipslayer67847

You need to replace each // Put our code here comment with actual code for it to work.