Use :input
, which selects all input elements, textarea, select, and button.
$(this).next(':input').focus();
jsFiddle
If the next input is not a sibling, this seems to work ... In this example, click the text field with id="test"
and it will focus
in the following element :input
.
<input type="text" value="hello world2"/> <input type="text" value="hello world3"/> <div> <input type="text" id="test"/> </div> <div> <div>Hi</div> </div> <textarea>found me</textarea> <input type="text" value="hello world"/> $(document).ready(function(){ $('#test').click(function(){ var c = $(this).parents().nextAll(':input:first').focus(); }); });
jsFiddle2
source share