이것은 기본적인 JS 코드입니다. JS를 배우고 싶은 친구들은 그것을 공부하거나 확장할 수 있습니다. JS를 사용하여 전체 키보드를 제어하는 것이 가장 좋습니다.
구체적인 코드는 다음과 같습니다.
다음과 같이 코드 코드를 복사합니다.
<스타일>
tr.highlight{배경:#08246B;색상:흰색;}
</style>
<테이블 ID="얼음">
<tr>
<td><input type='text'></td>
<td><input type='text'></td>
<td><input type='text'></td>
<td><input type='text'></td>
</tr>
<tr>
<td><input type='text'></td>
<td><input type='text'></td>
<td><input type='text'></td>
<td><input type='text'></td>
</tr>
<tr>
<td><input type='text'></td>
<td><input type='text'></td>
<td><input type='text'></td>
<td><input type='text'></td>
</tr>
<tr>
<td><input type='text'></td>
<td><input type='text'></td>
<td><input type='text'></td>
<td><input type='text'></td>
</tr>
<tr>
<td><input type='text'></td>
<td><input type='text'></td>
<td><input type='text'></td>
<td><input type='text'></td>
</tr>
</table>
<스크립트 언어="자바스크립트">
<!--
//초기화 큐 정의
var currentLine=-1;
var currentCol=-1;
document.onkeydown=function(e){
e=window.event||e;
스위치(e.keyCode){
사례 37: //왼쪽 클릭
currentCol--;
변경항목();
부서지다;
사례 38: //위쪽 키
현재라인--;
변경항목();
부서지다;
사례 39: //오른쪽 클릭
currentCol++;
변경항목();
부서지다;
사례 40: //아래쪽 키
currentLine++;
변경항목();
부서지다;
기본:
부서지다;
}
}
//방향키 호출
함수 변경항목(){
if(문서.모두)
var it=document.getElementByIdx_x("ice").children[0];
또 다른
var it=document.getElementByIdx_x("ice");
for(i=0;i<it.rows.length;i++){
it.rows[i].className="";
}
if(현재라인<0){
currentLine=it.rows.length-1;
}
if(currentLine==it.rows.length){
현재라인=0;
}
var objtab=document.all.ice;
var objrow=objtab.rows[currentLine].getElementsByTagName_r("INPUT");
if(현재Col<0){
currentCol=objrow.length-1;
}else if(currentCol==objrow.length){
현재Col=0;
}
objrow[currentCol].select();
//디버깅 사용
it.rows[currentLine].className="강조 표시";
}
//-->
</script>