Home > Web Front-end > JS Tutorial > Operation of javascript keyboard up and down keys (selection)_javascript skills

Operation of javascript keyboard up and down keys (selection)_javascript skills

WBOY
Release: 2016-05-16 19:04:02
Original
1727 people have browsed it

Two paragraphs of code for selecting using the up and down keys of the keyboard:
First paragraph


[Ctrl A Select all Note: If you need to introduce external Js, you need to refresh to execute
]
Second paragraph

[Ctrl A select all Note:
If you need to introduce external Js, you need to refresh to execute
]<script> var i=0; function document.onkeydown(){ if (event.keyCode == 38){ 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== 40){ 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>
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template