var inputs = $("#tb_Content input"); $("#tb_Content input").keydown(function (event) { if("[13][38][40]".indexOf("["+event.keyCode+"]")>-1){ if (event.target.type == "submit" && event.keyCode == 13) return; var index = 0; for (; index < inputs.length; index++) if ($(inputs[index]).attr("id") == event.target.id) break; switch (event.keyCode) { case 13: //回车键 case 40: //下 index++; break; case 38: //上 index--; break; } if (index == inputs.length) index = 0; if (index < 0) index = inputs.length - 1; $(inputs[index]).focus(); return false; } });