键盘控制div上下左右移动 (转)

<html> <head> <title></title> <link rel="stylesheet" type="text/css" href="public/easy_ui/themes/icon.css"> <script type="text/javascript" src="public/easy_ui/jquery.min.js"></script> <script type="text/javascript" src="public/easy_ui/easy_ui.min.js"></script> <script type="text/javascript" src="public/easy_ui/easyloader.js"></script> </head> <body> <div id="div" style="background-color: red; width: 400px; height: 300px; left: 100px; top: 100px;"> </div> </body> <script> $(function(){ $(document).keydown(function (event) { var keyCode = event.keyCode; var space = 20; var div = $('#div'); switch(keyCode){ case 37: div.offset({left:(div.offset().left - 20)}); break; case 38: div.offset({top:(div.offset().top - 20)}); break; case 39: div.offset({left:(div.offset().left + 20)}); break; case 40: div.offset({top:(div.offset().top + 20)}); break; default: break; } }); }); </script> </html> http://www.cnblogs.com/cglWorkBook/p/5134698.html  
上一篇:***LINUX添加PHP环境变量:CentOS下将php和mysql命令加入到环境变量中


下一篇:mac下设置JAVA_HOME环境变量