Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 上下移动
- var tt = box.offsetTop;
- mouseWheel(tB,function(ev,down){
- if(down){
- tt+=10;
- box.style.top = tt + "px";
- }else{
- tt-=10;
- box.style.top = tt + "px";
- }
- })
- 左右移动
- var ll = box.offsetLeft;
- mouseWheel(lr,function(ev,down){
- if(down){
- ll+= 10;
- box.style.left = ll + "px";
- }else{
- ll-=10;
- box.style.left = ll + "px";
- }
- })
- 变大变小
- var w = box.offsetWidth;
- mouseWheel(bs,function(ev,down){
- if(down){
- w+=10;
- box.style.width = box.style.height = w + "px";
- }else{
- w-=10;
- box.style.width = box.style.height = w + "px";
- }
- })
- //第一个
- but[0].onclick=function(){
- this.style.background="red";
- but[1].style.background="#ccc"
- but[2].style.background="#ccc"
- but[3].style.background="#ccc"
- but[4].style.background="#ccc"
- but[5].style.background="#ccc"
- but[6].style.background="#ccc"
- but[7].style.background="#ccc"
- but[8].style.background="#ccc"
- }
- but[0].onkeypress=function(ev){
- if(ev.keyCode==100){
- but[1].focus();
- but[1].style.background="red";
- but[0].style.background="#ccc";
- }else if(ev.keyCode==115){
- but[3].focus();
- but[3].style.background="red"
- but[0].style.background="#ccc"
- }else if(ev.keyCode==97){
- but[2].focus();
- but[2].style.background="red"
- but[0].style.background="#ccc"
- }else if(ev.keyCode==119){
- but[6].focus();
- but[6].style.background="red"
- but[0].style.background="#ccc"
- }
- }
- //第二个
- but[1].onclick=function(){
- this.style.background="red";
- but[0].style.background="#ccc"
- but[2].style.background="#ccc"
- but[3].style.background="#ccc"
- but[4].style.background="#ccc"
- but[5].style.background="#ccc"
- but[6].style.background="#ccc"
- but[7].style.background="#ccc"
- but[8].style.background="#ccc"
- }
- but[1].onkeypress=function(ev){
- if(ev.keyCode==97){
- but[0].focus();
- but[0].style.background="red";
- but[1].style.background="#ccc";
- }else if(ev.keyCode==115){
- but[4].focus();
- but[4].style.background="red"
- but[1].style.background="#ccc";
- }else if(ev.keyCode==100){
- but[2].focus();
- but[2].style.background="red"
- but[1].style.background="#ccc";
- }else if(ev.keyCode==119){
- but[7].focus();
- but[7].style.background="red"
- but[1].style.background="#ccc"
- }
- }
- //第三个
- but[2].onclick=function(){
- this.style.background="red";
- but[0].style.background="#ccc"
- but[1].style.background="#ccc"
- but[3].style.background="#ccc"
- but[4].style.background="#ccc"
- but[5].style.background="#ccc"
- but[6].style.background="#ccc"
- but[7].style.background="#ccc"
- but[8].style.background="#ccc"
- }
- but[2].onkeypress=function(ev){
- if(ev.keyCode==97){
- but[1].focus();
- but[1].style.background="red";
- but[2].style.background="#ccc";
- }else if(ev.keyCode==115){
- but[5].focus();
- but[5].style.background="red"
- but[2].style.background="#ccc"
- }else if(ev.keyCode==119){
- but[8].focus();
- but[8].style.background="red"
- but[2].style.background="#ccc"
- }else if(ev.keyCode==100){
- but[0].focus();
- but[0].style.background="red"
- but[2].style.background="#ccc"
- }
- }
- //第四个
- but[3].onclick=function(){
- this.style.background="red";
- but[0].style.background="#ccc"
- but[2].style.background="#ccc"
- but[1].style.background="#ccc"
- but[4].style.background="#ccc"
- but[5].style.background="#ccc"
- but[6].style.background="#ccc"
- but[7].style.background="#ccc"
- but[8].style.background="#ccc"
- }
- but[3].onkeypress=function(ev){
- if(ev.keyCode==119){
- but[0].focus();
- but[0].style.background="red";
- but[3].style.background="#ccc"
- }else if(ev.keyCode==100){
- but[4].focus();
- but[4].style.background="red"
- but[3].style.background="#ccc"
- }else if(ev.keyCode==115){
- but[6].focus();
- but[6].style.background="red"
- but[3].style.background="#ccc"
- }else if(ev.keyCode==97){
- but[5].focus();
- but[5].style.background="red"
- but[3].style.background="#ccc"
- }
- }
- //第五个
- but[4].onclick=function(){
- this.style.background="red";
- but[0].style.background="#ccc"
- but[2].style.background="#ccc"
- but[1].style.background="#ccc"
- but[3].style.background="#ccc"
- but[5].style.background="#ccc"
- but[6].style.background="#ccc"
- but[7].style.background="#ccc"
- but[8].style.background="#ccc"
- }
- but[4].onkeypress=function(ev){
- if(ev.keyCode==119){
- but[1].focus();
- but[1].style.background="red";
- but[4].style.background="#ccc";
- }else if(ev.keyCode==97){
- but[3].focus();
- but[4].style.background="#ccc";
- but[3].style.background="red"
- }else if(ev.keyCode==100){
- but[5].focus();
- but[4].style.background="#ccc";
- but[5].style.background="red"
- }else if(ev.keyCode==115){
- but[7].focus();
- but[4].style.background="#ccc";
- but[7].style.background="red"
- }
- }
- //第六个
- but[5].onclick=function(){
- this.style.background="red";
- but[0].style.background="#ccc"
- but[2].style.background="#ccc"
- but[1].style.background="#ccc"
- but[4].style.background="#ccc"
- but[3].style.background="#ccc"
- but[6].style.background="#ccc"
- but[7].style.background="#ccc"
- but[8].style.background="#ccc"
- }
- but[5].onkeypress=function(ev){
- if(ev.keyCode==119){
- but[2].focus();
- but[2].style.background="red";
- but[5].style.background="#ccc"
- }else if(ev.keyCode==97){
- but[4].focus();
- but[4].style.background="red"
- but[5].style.background="#ccc"
- }else if(ev.keyCode==115){
- but[8].focus();
- but[8].style.background="red"
- but[5].style.background="#ccc"
- }else if(ev.keyCode==100){
- but[3].focus();
- but[3].style.background="red"
- but[5].style.background="#ccc"
- }
- }
- //第七个
- but[6].onclick=function(){
- this.style.background="red";
- but[0].style.background="#ccc"
- but[2].style.background="#ccc"
- but[1].style.background="#ccc"
- but[4].style.background="#ccc"
- but[5].style.background="#ccc"
- but[3].style.background="#ccc"
- but[7].style.background="#ccc"
- but[8].style.background="#ccc"
- }
- but[6].onkeypress=function(ev){
- if(ev.keyCode==119){
- but[3].focus();
- but[3].style.background="red";
- but[7].style.background="#ccc";
- but[6].style.background="#ccc"
- }else if(ev.keyCode==100){
- but[7].focus();
- but[7].style.background="red"
- but[3].style.background="#ccc"
- but[6].style.background="#ccc"
- }else if(ev.keyCode==115){
- but[0].focus();
- but[0].style.background="red"
- but[6].style.background="#ccc"
- }else if(ev.keyCode==97){
- but[8].focus();
- but[8].style.background="red"
- but[6].style.background="#ccc"
- }
- }
- //第八个
- but[7].onclick=function(){
- this.style.background="red";
- but[0].style.background="#ccc"
- but[2].style.background="#ccc"
- but[1].style.background="#ccc"
- but[4].style.background="#ccc"
- but[5].style.background="#ccc"
- but[6].style.background="#ccc"
- but[3].style.background="#ccc"
- but[8].style.background="#ccc"
- }
- but[7].onkeypress=function(ev){
- if(ev.keyCode==119){
- but[4].focus();
- but[4].style.background="red";
- but[7].style.background="#ccc";
- }else if(ev.keyCode==97){
- but[6].focus();
- but[6].style.background="red"
- but[7].style.background="#ccc"
- }else if(ev.keyCode==100){
- but[8].focus();
- but[8].style.background="red"
- but[7].style.background="#ccc"
- }else if(ev.keyCode==115){
- but[1].focus();
- but[1].style.background="red"
- but[7].style.background="#ccc"
- }
- }
- //第九个
- but[8].onclick=function(){
- this.style.background="red";
- but[0].style.background="#ccc"
- but[2].style.background="#ccc"
- but[1].style.background="#ccc"
- but[4].style.background="#ccc"
- but[5].style.background="#ccc"
- but[6].style.background="#ccc"
- but[7].style.background="#ccc"
- but[3].style.background="#ccc"
- }
- but[8].onkeypress=function(ev){
- console.log(ev.keyCode)
- if(ev.keyCode==119){
- but[5].focus();
- but[5].style.background="red";
- but[8].style.background="#ccc"
- }else if(ev.keyCode==97){
- but[7].focus();
- but[7].style.background="red"
- but[8].style.background="#ccc"
- }else if(ev.keyCode==115){
- but[2].focus();
- but[2].style.background="red"
- but[8].style.background="#ccc"
- }else if(ev.keyCode==100){
- but[6].focus();
- but[6].style.background="red"
- but[8].style.background="#ccc"
- }
- }
- a.onkeypress=function(ev){
- if(ev.keyCode==119){
- a.style.background="red";
- }
- }
- // function myy(){
- // return this.style.background="#ccc";
- // }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement