jquery collision detection for divs
问题 I'm trying to learn some programming with jQuery. I have a div that has 800 x 800 pixel dimensions. I have another 16 x 16 pixel div that I want to move within the bigger one using arrow keys. Problem is I can't get it to work properly, can someone please tell me what I'm doing wrong. Moving left works, it stops the 16x16 div if css attribute "left" is under 0px: $(this).keydown(function(e) { if (e.which == '37' && ($('#p1').css('left') > "0px")) { $('#p1').css('left', '-=16px') } }); Moving