zoukankan
html css js c++ java
键盘控制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
查看全文
相关阅读:
luogu P3238 [HNOI2014]道路堵塞
luogu P3235 [HNOI2014]江南乐
luogu P3237 [HNOI2014]米特运输
luogu P3233 [HNOI2014]世界树
luogu P3234 [HNOI2014]抄卡组
luogu P3250 [HNOI2016]网络
luogu P3201 [HNOI2009]梦幻布丁
luogu P4148 简单题
luogu P3767 膜法
luogu P4314 CPU监控
原文地址:https://www.cnblogs.com/softidea/p/5269810.html
最新文章
[xdoj1227]Godv的数列(crt+lucas)
lintcode-18-带重复元素的子集
lintcode-17-子集
lintcode-16-带重复元素的排列
lintcode-15-全排列
lintcode-14-二分查找
lintcode-13-字符串查找
lintcode-11-二叉查找树中搜索区间
lintcode-6-合并排序数组
lintcode-2-尾部的零
热门文章
LintCode-7-二叉树的序列化和反序列化
CF939F Cutlet (单调队列优化DP)
CF1000G Two-Paths (树形DP)
CF1015F Bracket Substring (KMP+DP)
CF915F Imbalance Value of a Tree (并查集)
CF1065D Three Pieces (多元最短路)
拓展Lucas小结
BZOJ 3129 [SDOI2013]方程 (拓展Lucas)
CF451E Devu and Flowers (组合数学+容斥)
CF1005F Berland and the Shortest Paths (树上构造最短路树)
Copyright © 2011-2022 走看看