Advertisement
Guest User

Untitled

a guest
Feb 19th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.91 KB | None | 0 0
  1. 上下移动
  2. var tt = box.offsetTop;
  3. mouseWheel(tB,function(ev,down){
  4. if(down){
  5. tt+=10;
  6. box.style.top = tt + "px";
  7. }else{
  8. tt-=10;
  9. box.style.top = tt + "px";
  10. }
  11.  
  12. })
  13.  
  14. 左右移动
  15. var ll = box.offsetLeft;
  16. mouseWheel(lr,function(ev,down){
  17. if(down){
  18. ll+= 10;
  19. box.style.left = ll + "px";
  20. }else{
  21. ll-=10;
  22. box.style.left = ll + "px";
  23. }
  24. })
  25.  
  26. 变大变小
  27. var w = box.offsetWidth;
  28. mouseWheel(bs,function(ev,down){
  29. if(down){
  30. w+=10;
  31. box.style.width = box.style.height = w + "px";
  32. }else{
  33. w-=10;
  34. box.style.width = box.style.height = w + "px";
  35. }
  36. })
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73. //第一个
  74. but[0].onclick=function(){
  75. this.style.background="red";
  76. but[1].style.background="#ccc"
  77. but[2].style.background="#ccc"
  78. but[3].style.background="#ccc"
  79. but[4].style.background="#ccc"
  80. but[5].style.background="#ccc"
  81. but[6].style.background="#ccc"
  82. but[7].style.background="#ccc"
  83. but[8].style.background="#ccc"
  84.  
  85. }
  86. but[0].onkeypress=function(ev){
  87. if(ev.keyCode==100){
  88. but[1].focus();
  89. but[1].style.background="red";
  90. but[0].style.background="#ccc";
  91. }else if(ev.keyCode==115){
  92. but[3].focus();
  93. but[3].style.background="red"
  94. but[0].style.background="#ccc"
  95. }else if(ev.keyCode==97){
  96. but[2].focus();
  97. but[2].style.background="red"
  98. but[0].style.background="#ccc"
  99. }else if(ev.keyCode==119){
  100. but[6].focus();
  101. but[6].style.background="red"
  102. but[0].style.background="#ccc"
  103. }
  104. }
  105. //第二个
  106. but[1].onclick=function(){
  107. this.style.background="red";
  108. but[0].style.background="#ccc"
  109. but[2].style.background="#ccc"
  110. but[3].style.background="#ccc"
  111. but[4].style.background="#ccc"
  112. but[5].style.background="#ccc"
  113. but[6].style.background="#ccc"
  114. but[7].style.background="#ccc"
  115. but[8].style.background="#ccc"
  116. }
  117. but[1].onkeypress=function(ev){
  118. if(ev.keyCode==97){
  119. but[0].focus();
  120. but[0].style.background="red";
  121. but[1].style.background="#ccc";
  122. }else if(ev.keyCode==115){
  123. but[4].focus();
  124. but[4].style.background="red"
  125. but[1].style.background="#ccc";
  126. }else if(ev.keyCode==100){
  127. but[2].focus();
  128. but[2].style.background="red"
  129. but[1].style.background="#ccc";
  130. }else if(ev.keyCode==119){
  131. but[7].focus();
  132. but[7].style.background="red"
  133. but[1].style.background="#ccc"
  134. }
  135. }
  136. //第三个
  137. but[2].onclick=function(){
  138. this.style.background="red";
  139. but[0].style.background="#ccc"
  140. but[1].style.background="#ccc"
  141. but[3].style.background="#ccc"
  142. but[4].style.background="#ccc"
  143. but[5].style.background="#ccc"
  144. but[6].style.background="#ccc"
  145. but[7].style.background="#ccc"
  146. but[8].style.background="#ccc"
  147. }
  148. but[2].onkeypress=function(ev){
  149. if(ev.keyCode==97){
  150. but[1].focus();
  151. but[1].style.background="red";
  152. but[2].style.background="#ccc";
  153. }else if(ev.keyCode==115){
  154. but[5].focus();
  155. but[5].style.background="red"
  156. but[2].style.background="#ccc"
  157. }else if(ev.keyCode==119){
  158. but[8].focus();
  159. but[8].style.background="red"
  160. but[2].style.background="#ccc"
  161. }else if(ev.keyCode==100){
  162. but[0].focus();
  163. but[0].style.background="red"
  164. but[2].style.background="#ccc"
  165. }
  166. }
  167. //第四个
  168. but[3].onclick=function(){
  169. this.style.background="red";
  170. but[0].style.background="#ccc"
  171. but[2].style.background="#ccc"
  172. but[1].style.background="#ccc"
  173. but[4].style.background="#ccc"
  174. but[5].style.background="#ccc"
  175. but[6].style.background="#ccc"
  176. but[7].style.background="#ccc"
  177. but[8].style.background="#ccc"
  178. }
  179. but[3].onkeypress=function(ev){
  180. if(ev.keyCode==119){
  181. but[0].focus();
  182. but[0].style.background="red";
  183. but[3].style.background="#ccc"
  184. }else if(ev.keyCode==100){
  185. but[4].focus();
  186. but[4].style.background="red"
  187. but[3].style.background="#ccc"
  188. }else if(ev.keyCode==115){
  189. but[6].focus();
  190. but[6].style.background="red"
  191. but[3].style.background="#ccc"
  192. }else if(ev.keyCode==97){
  193. but[5].focus();
  194. but[5].style.background="red"
  195. but[3].style.background="#ccc"
  196. }
  197. }
  198. //第五个
  199. but[4].onclick=function(){
  200. this.style.background="red";
  201. but[0].style.background="#ccc"
  202. but[2].style.background="#ccc"
  203. but[1].style.background="#ccc"
  204. but[3].style.background="#ccc"
  205. but[5].style.background="#ccc"
  206. but[6].style.background="#ccc"
  207. but[7].style.background="#ccc"
  208. but[8].style.background="#ccc"
  209. }
  210. but[4].onkeypress=function(ev){
  211. if(ev.keyCode==119){
  212. but[1].focus();
  213. but[1].style.background="red";
  214. but[4].style.background="#ccc";
  215. }else if(ev.keyCode==97){
  216. but[3].focus();
  217. but[4].style.background="#ccc";
  218. but[3].style.background="red"
  219. }else if(ev.keyCode==100){
  220. but[5].focus();
  221. but[4].style.background="#ccc";
  222. but[5].style.background="red"
  223. }else if(ev.keyCode==115){
  224. but[7].focus();
  225. but[4].style.background="#ccc";
  226. but[7].style.background="red"
  227. }
  228. }
  229. //第六个
  230. but[5].onclick=function(){
  231. this.style.background="red";
  232. but[0].style.background="#ccc"
  233. but[2].style.background="#ccc"
  234. but[1].style.background="#ccc"
  235. but[4].style.background="#ccc"
  236. but[3].style.background="#ccc"
  237. but[6].style.background="#ccc"
  238. but[7].style.background="#ccc"
  239. but[8].style.background="#ccc"
  240. }
  241. but[5].onkeypress=function(ev){
  242. if(ev.keyCode==119){
  243. but[2].focus();
  244. but[2].style.background="red";
  245. but[5].style.background="#ccc"
  246. }else if(ev.keyCode==97){
  247. but[4].focus();
  248. but[4].style.background="red"
  249. but[5].style.background="#ccc"
  250. }else if(ev.keyCode==115){
  251. but[8].focus();
  252. but[8].style.background="red"
  253. but[5].style.background="#ccc"
  254. }else if(ev.keyCode==100){
  255. but[3].focus();
  256. but[3].style.background="red"
  257. but[5].style.background="#ccc"
  258.  
  259. }
  260. }
  261. //第七个
  262. but[6].onclick=function(){
  263. this.style.background="red";
  264. but[0].style.background="#ccc"
  265. but[2].style.background="#ccc"
  266. but[1].style.background="#ccc"
  267. but[4].style.background="#ccc"
  268. but[5].style.background="#ccc"
  269. but[3].style.background="#ccc"
  270. but[7].style.background="#ccc"
  271. but[8].style.background="#ccc"
  272. }
  273. but[6].onkeypress=function(ev){
  274. if(ev.keyCode==119){
  275. but[3].focus();
  276. but[3].style.background="red";
  277. but[7].style.background="#ccc";
  278. but[6].style.background="#ccc"
  279. }else if(ev.keyCode==100){
  280. but[7].focus();
  281. but[7].style.background="red"
  282. but[3].style.background="#ccc"
  283. but[6].style.background="#ccc"
  284. }else if(ev.keyCode==115){
  285. but[0].focus();
  286. but[0].style.background="red"
  287. but[6].style.background="#ccc"
  288. }else if(ev.keyCode==97){
  289. but[8].focus();
  290. but[8].style.background="red"
  291. but[6].style.background="#ccc"
  292.  
  293. }
  294. }
  295. //第八个
  296. but[7].onclick=function(){
  297. this.style.background="red";
  298. but[0].style.background="#ccc"
  299. but[2].style.background="#ccc"
  300. but[1].style.background="#ccc"
  301. but[4].style.background="#ccc"
  302. but[5].style.background="#ccc"
  303. but[6].style.background="#ccc"
  304. but[3].style.background="#ccc"
  305. but[8].style.background="#ccc"
  306. }
  307. but[7].onkeypress=function(ev){
  308. if(ev.keyCode==119){
  309.  
  310. but[4].focus();
  311. but[4].style.background="red";
  312. but[7].style.background="#ccc";
  313. }else if(ev.keyCode==97){
  314. but[6].focus();
  315. but[6].style.background="red"
  316. but[7].style.background="#ccc"
  317.  
  318. }else if(ev.keyCode==100){
  319. but[8].focus();
  320. but[8].style.background="red"
  321. but[7].style.background="#ccc"
  322. }else if(ev.keyCode==115){
  323. but[1].focus();
  324. but[1].style.background="red"
  325. but[7].style.background="#ccc"
  326. }
  327. }
  328. //第九个
  329. but[8].onclick=function(){
  330. this.style.background="red";
  331. but[0].style.background="#ccc"
  332. but[2].style.background="#ccc"
  333. but[1].style.background="#ccc"
  334. but[4].style.background="#ccc"
  335. but[5].style.background="#ccc"
  336. but[6].style.background="#ccc"
  337. but[7].style.background="#ccc"
  338. but[3].style.background="#ccc"
  339.  
  340. }
  341. but[8].onkeypress=function(ev){
  342. console.log(ev.keyCode)
  343. if(ev.keyCode==119){
  344. but[5].focus();
  345. but[5].style.background="red";
  346. but[8].style.background="#ccc"
  347. }else if(ev.keyCode==97){
  348. but[7].focus();
  349. but[7].style.background="red"
  350. but[8].style.background="#ccc"
  351. }else if(ev.keyCode==115){
  352. but[2].focus();
  353. but[2].style.background="red"
  354. but[8].style.background="#ccc"
  355. }else if(ev.keyCode==100){
  356. but[6].focus();
  357. but[6].style.background="red"
  358. but[8].style.background="#ccc"
  359.  
  360. }
  361. }
  362. a.onkeypress=function(ev){
  363. if(ev.keyCode==119){
  364. a.style.background="red";
  365.  
  366. }
  367. }
  368. // function myy(){
  369. // return this.style.background="#ccc";
  370. // }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement