HTML
<input class="fr pinPass" type="password" name="pin1" id="pin1_1" tabindex="100"/>
<label>Enter the third number</label>
<br class="cb"/>
<input class="fr pinPass" type="password" name="pin1" id="pin1_2" tabindex="101"/>
<label>Enter the fourth number</label>
<br class="cb"/>
<input class="fr pinPass" type="password" name="pin1" id="pin1_3" tabindex="102"/>
<label>Enter the second number</label>
当前的jQuery
$(".pinPass").focus(function () {
$(this).keyup(function(){
$("input").siblings('.pinPass').filter(':first').focus();
});
});
问题:
我试图在每个输入字段中的keyUp之后的下一个输入字段上设置autoFocus。 到目前为止,我已经提出了一直保持循环直到它被选中的最后一个解决方案,或者如果我使用:first filter,它总是返回到它在页面上找到的第一个。
我认为我不能使用next(),因为它不是集合中的下一个节点。 每个输入字段总会有标签分隔。
非常感谢任何帮助。
答案 0 :(得分:3)
您可以使用:first
,但.next()
只会返回非常的下一个 相反,您希望.nextAll()
使用选择器,如下所示:
$(".pinPass").keyup(function(){
$(this).nextAll('.pinPass:first').focus();
});
答案 1 :(得分:0)
接下来可以有选择器。
$(this).next('input');