zoukankan      html  css  js  c++  java
  • [转]js 回车转成TAB(利用tabindex)

    <!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

  • 相关阅读:
    Pandas to_sql将DataFrame保存的数据库中
    Pandas 的groupby操作
    Hibernate(一)
    EasyUI
    Java面试题
    Solr
    Lucene
    SpringMVC(二)
    MyBatis(二)
    MyBatis(一)
  • 原文地址:https://www.cnblogs.com/freeliver54/p/6866035.html
Copyright © 2011-2022 走看看