Two paragraphs using the keyboard's upper and lower keys to select the code:
First Paragraph
<script language= "JScript" > Function Document.onkeydown () {var rowsarray = document.all (' otable ' ). Rows; for (Var i=0;i<rowsarray.length;i++) {if (rowsarray[i].children[0].style.backgroundcolor== ' #dcdcdc ') { Switch (window.event.keyCode) {case 38:if (i-1>=0) { Rowsarray[i-1].children[0].style.backgroundcolor = ' #dcdcdc '; Rowsarray[i].children[0].style.backgroundcolor = '; } break; Case 40:if (i+1<=rowsarray.length-1) {Rowsarray[i+1].children [0].style.backgroundcolor = ' #dcdcdc '; Rowsarray[i].children[0].style.backgroundcolor = '; } break; } break; }} function Document.onclick () {if (window.event.srcElement.tagNa me!= ' TD ') {return;} var Rowsarray = document.all (' otable '). Rows; for (Var i=0;i<rowsarray.length;i++) {if (rowsarray[i].cells[0]==window.event.srcelement) { Rowsarray[i].cells[0].style.backgroundcolor = ' #dcdcdc '; }else{rowsarray[i].cells[0].style.backgroundcolor = '; }} </Script> <style> TD {cursor:hand} </style> <table id= " Otable "> <tr> <td > Mouse click or press ↑↓ to change line's color </td> </tr> <tr> <td> mouse click or press ↑↓ to change the line color </td> </tr> <tr> <td> Mouse click or press ↑↓ to change the line color </TD&G T </tr> <tr> <td> Mouse clicks or press ↑↓ to change the color of the line </td> </tr> </table>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]
second paragraph
<table id= "TB" > <tr><td>00000000000000</td> </tr> <tr><td>111111111111 11</td> </tr> <tr><td>22222222222222</td></tr> <tr><td>3333333333 3333</td></tr> </table> <script> var i=0; function Document.onkeydown () {if (Event.keycode = =) {for (Var K=0;k<document.getelementbyid (' TB '). rows.length;k++) {document.getElementById (' TB '). Rows (k). bgcolor= ""; } document.getElementById (' TB '). Rows (--i%tb.rows.length). bgcolor= "#FF0000"; Document.all.show.value=document.getelementbyid (' TB '). Rows (i%tb.rows.length). innertext; } if (event.keycode==) {for (Var K=0;k<document.getelementbyid (' TB '). rows.length;k++) { document.getElementById (' TB '). Rows (k). bgcolor= ""; } document.getElementById (' TB '). Rows (++i%document.getelementbyid (' TB '). Rows.length). bgcolor= "#FF0000"; Document.all.show.value=document.getelementbyid (' TB '). Rows (i%tb.rows.length). innertext; } </script> <input type= ' text ' name= ' show ' value= ' do ' >
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]