8. The .keydown() Event


#1

Nothing happens but my code passed.

$(document).ready(function() {
$(document).keydown(function() {
$("div").animate({left: '+= 10px'}, 500);
});
});

I clicked in the full screen and held down a key on the keyboard but nothing happened. Tried to refresh the browser but that didn't do anything.


#2

Hi James,

Are you clicking on the <div> and pressing the Space key after submitting your code?
You'll need to do that (or press any key, it doesn't matter which one) for it to move :slight_smile:


#3

Yes I tried all that. Oh well, I'll take it for granted that it works. Onto the the next problem!


#4

Try removing the space between += and 10px.


#5

the space wont affect anything.... Unless its Codecademy's Fault.. Glad its working @textrockstar34699


#6

A post was split to a new topic: Exercise 8 not working for me, why?


#8

The space in left:'+= 10px' was the problem for me. Remove it and it will be fine


#9

Same problem, I have successfully finished the section but the Red Square remains at it's place. (I followed the instruction)


#10

@divscode24 if you used single quotes around 'div' selector, change these to double quotes, worked for me
$("div").animate({left:'+=10px'},500);


#11

If you need help please create your own topic with full details


#12