I found this in the Archive 8/10


#1

Hi, Im Using Chrome with a mac..this work for me..
$(document).ready(function(){
$(this).keydown(function(){
$('div').animate({left:'+=10px'}, 500)
});
});

Why is the code for Mac different? When I put 'div' in both nohting happens. I follow this code, the 'div' moves. How come?


#2

Hi Mark,

The code for Apple computers isn't any different.
In that code, $(this) is referencing document; the entire page, so you can click anywhere and press a key, and the <div> will move. When you use $('div') on line 2 though, you have to click on the <div>, then press a key, for it to move.

Are you maybe not clicking in the right place, and that might be why it's not moving when you use $('div') both times?