一段小脚本
实现功能:文本框回车切换焦点
<script>
function foo(){
var items=document.getElementsByName('key[]');
var item=null;
for(var i=0;i<items.length;i++){
item=items[i];
(function () {
var next=(i+1) < items.length ? i+1 : 0 ;
item.οnkeydοwn=function(event){
var eve=event ? event : window.event;
if(eve.keyCode==13){
items[next].focus();
}
}
})();
}
}
window.οnlοad=foo;
</script>
<form action="" name="myform">
<Input type=text name='key[]'> <br>
<Input type=text name='key[]'> <br>
<Input type=text name='key[]'>
</form>