<script type="text/javascript">
$(function() {
$('input:text:first').focus();
var $inp = $('.cls');
$inp.bind('keydown', function(e) {
var key = e.which;
if (key == 13) {
e.preventDefault();
var nxtIdx = $inp.index(this) + 1;
$(".cls:eq(" + nxtIdx + ")").focus();
}
});
});
</script>
需要切换的input空间定义 class = "cls" 即可
<input type="button" value="确定" id="okbtn" class = "cls"/>
<input type="button" value="取消" id="cancelbtn" class ="cls"/>