搜索
首页 电脑/网络 操作系统/系统故障

用键盘上下键实现表格行的上下选择的JS代码需要用到什么代码?

用键盘上下键实现表格行的上下选择的JS代码需要用到什么代码?

全部回答

2018-10-27

1 0
    【实例代码】htmlheadtitle键盘方向键控制表格-学无忧(www。xue51。com)/title/headbody onKeyDown=keyCheck();table width=80 bgcolor=#FFFFFF height=60 border=1 bordercolor=#FFFFFF cellpadding=0 cellspacing=0 trtd id=td1 width=80第一行/td /tr trtd id=td2 width=80第二行/td /tr trtd id=td3 width=80第三行/td /tr trtd id=td4 width=80第四行/td /tr trtd id=td5 width=80第五行/td /tr trtd id=td6 width=80第六行/td /tr/tablescript language=javascriptvar tdIndex = 1; //获取当前行的索引变量document。
    all。td1。style。backgroundColor='#3366aa'; //设置列1的背景色function keyCheck() {if (window。event。
  keyCode==38) { //向上键for (var i=1;i=6;i++) {eval(document。  all。td+i+。style。backgroundColor='#FFFFFF');//更改所有的行背景色}if (tdIndex=1) {document。
  all。td1。style。backgroundColor='#3366aa'; //到顶端时,只第一行颜色改变alert('已到顶端');return false;}else {tdIndex -= 1; //行索引减小eval(document。
    all。td+tdIndex+。style。backgroundColor='#3366aa');//改变行的背景色}}if (window。event。keyCode==40) { //向下键for (var i=1;i=6;i++) {eval(document。
    all。td+i+。style。backgroundColor='#FFFFFF');//更改所有的行背景色}if (tdIndex=6) {document。all。
  td6。style。backgroundColor='#3366aa'; //到顶端时,只第一行颜色改变alert('已到底端');return false;}else {tdIndex += 1; //行索引增加eval(document。
    all。td+tdIndex+。style。backgroundColor='#3366aa');//改变行的背景色}}}/script/body/html。

类似问题换一批

热点推荐

热度TOP

相关推荐
加载中...

热点搜索 换一换

电脑/网络
操作系统/系统故障
硬件
电脑装机
程序设计
互联网
笔记本电脑
反病毒
百度
软件
操作系统/系统故障
操作系统/系统故障
举报
举报原因(必选):
取消确定举报