<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
02.<html xmlns="http://www.w3.org/1999/xhtml">  
03.<head>  
04.<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  
05.<script type="text/javascript">  
06.function enterToTab(event, input) {  
07.    var e = event?event:window.event;  
08.    var form = document.getElementById('form1');  
09.    if(e.keyCode == 13) {  
10.        var tabindex = input.getAttribute('tabindex');  
11.        tabindex++;  
12.        var inputs = form.getElementsByTagName('input');  
13.        for(var i=0,j=inputs.length;  i<j; i++) {  
14.            if (inputs[i].getAttribute('tabindex') == tabindex) {  
15.                inputs[i].focus();  
16.                break;  
17.            }  
18.        }  
19.    }  
20.}  
21.</script>  
22.</head>  
23.<body>  
24.<form id="form1">  
25.<input type="text"  tabindex="1" onkeydown="enterToTab(event,this);"/>  
26.<input type="text"   tabindex="2" onkeydown="enterToTab(event,this);"/>  
27.<input type="text"   tabindex="3" onkeydown="enterToTab(event,this);"/>  
28.<input type="text"   tabindex="4" onkeydown="enterToTab(event,this);"/>  
29.<input type="button" value="click me" onclick="alert('I'm here!')"  tabindex="5" onkeydown="enterToTab(event,this);"/>  
30.</form>  
31.</body>  
32.</html>  

 

本文转自:http://blog.csdn.net/djchallenge/article/details/7325844

 

相关文章:

  • 2021-09-16
  • 2021-07-26
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-21
  • 2021-07-03
猜你喜欢
  • 2021-12-28
  • 2022-01-25
  • 2022-12-23
  • 2022-02-08
  • 2022-02-22
相关资源
相似解决方案