$(function(){ $("input").keydown(function(){ if(13 == event.keyCode){ var form = $("body"); var inputEles = form.find("input:visible"); console.log("inputEles -> "+inputEles.length); //5 for(var i=0;i<inputEles.length;i++){ if($(inputEles[i]).is($(the this ))) { // determines whether two objects are equal with jQuery IS IF (I == inputEles.length- . 1 ) { $ (inputEles [ 0 ]) Focus ();. } the else { $ (inputEles [I + . 1 ]) Focus ();. } } } } }); })