表單切換,用回車鍵替換Tab健(不支持IE)
更新時間:2011年07月20日 20:52:32 作者:
表單切換,用回車鍵替換Tab健。input的屬性tab的值表示切換的順序,這個值必須是連續(xù)的,并且不能重復(fù)。目前不支持IE
復(fù)制代碼 代碼如下:
<div>
<form>
<input name="a" tab="1" />
<input name="a" tab="3" />
<input name="a" tab="2" />
<input name="a" tab="5" />
<input name="a" tab="4" />
<input type="submit" value="submit" />
</form>
</div>
<script type="text/javascript">
var inputs = document.getElementsByTagName("input");
for (i = 0; i < inputs.length; i++) {
inputs[i].onkeydown = function(e){
if (e.keyCode == 13) {
var input = getInputByTab(parseInt(this.getAttribute("tab")) + 1);
if (input) {
input.focus();
return false;
}
}
}
}
function getInputByTab(t) {
for (i =0; i < inputs.length; i++) {
if (inputs[i].getAttribute("tab") == t)
return inputs[i];
}
return false;
}
</script>
相關(guān)文章
JavaScript高級程序設(shè)計 客戶端存儲學(xué)習(xí)筆記
JavaScript高級程序設(shè)計 客戶端存儲學(xué)習(xí)筆記,在客戶端用于存儲會話信息2011-09-09Extjs顯示從數(shù)據(jù)庫取出時間轉(zhuǎn)換JSON后的出現(xiàn)問題
后臺從數(shù)據(jù)庫取出時間,JSON格式化后再傳到gridpanel,這時時間變成了:/Date(32331121223)/這樣的格式,本文將詳細(xì)介紹解決Extjs顯示從數(shù)據(jù)庫取出時間轉(zhuǎn)換JSON后的出現(xiàn)問題2012-11-11