Can't animate div


#1



so, i'm trying to make my div animated only if i focus on my div+i hold a key....but it seems like my animate code doesn't work
what is the wrong part?


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


#2

Hi Kevinmogi,

You're missing a case statement inside your switch statement. If you want it to work for any key, you could probably just remove the switch part and leave only the $('div').animate(...); piece inside the function there.


#3

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