You can use the upper and lower keys on the keyboard to select the implementation code of table rows. The idea is good. For more information, see.
// This is the table to be operated on: <table id = "tb"> <tr> <td> This is the first line </td> </tr> <td> This is the second line </td> </tr> <td> This is the third row </td> </tr> <td> This is the fourth row </td> </tr> </table> // This is the code used to operate the table. script var rowNo =-1; var tableId = 'tb'; var inputId = 'show'; var selectedColor = "# FF0000" function document. onkeydown () {// event ID code if (event. keyCode = 38) {for (var k = 0; k <document. getElementById (tableId ). rows. length; k ++) {document. getElementById (tableId ). rows (k ). bgColor = "# FFFFFF";} if (rowNo = 0) {rowNo ++;} document. getElementById (tableId ). rows (-- rowNo % document. getElementById (tableId ). rows. length ). bgColor = selectedColor; document. getElementById (inputId ). value = document. getElementById (tableId ). rows (rowNo % document. getElementById (tableId ). rows. length ). innerText;} // event identifier code if (event. keyCode = 40) {for (var k = 0; k <document. getElementById (tableId ). rows. length; k ++) {document. getElementById (tableId ). rows (k ). bgColor = "# FFFFFF";} document. getElementById (tableId ). rows (++ rowNo % document. getElementById (tableId ). rows. length ). bgColor = selectedColor; document. getElementById (inputId ). value = document. getElementById (tableId ). rows (rowNo % document. getElementById (tableId ). rows. length ). innerText ;}} script <input type = "text" id = "show" value = "do">
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]