Posted in Javascript onJuly 20, 2011
<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>
表单切换,用回车键替换Tab健(不支持IE)
声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@