挺有趣的,Jquery 回车切换tab功能的实现哦
<html><head>jquery库.js-->head><body><form>用户名:<input name='user'/>密码:<input name='pwd' type='password'/><input type='submit' value='登陆'/>form>body>html>
js:
jQuery(document).ready(function () { //按Enter鍵直接Tab $("input[name='user']:first").focus(); var $target = $("input[name='user'],input[name='pwd'],button[type='submit']"); $target.bind('keydown', function (e) { var key = e.which; if (key == 13) { e.preventDefault(); var nxtIdx = $target.index(this) + 1; if ($target.eq(nxtIdx).attr("type") == "submit") { $target.eq(nxtIdx).click(); } else { $target.eq(nxtIdx).focus(); } } }); //End });" _ue_custom_node_="true">