我有这个html:
<div class="field phone">
<input type="text" maxlength="3" />
</div>
<div class="field phone number1">
<input type="text" maxlength="3" />
</div>
<div class="field phone number2">
<input type="text" maxlength="4" />
</div>
然后我正在使用
$(".phone input:not(:last)").keydown(function() {
var that = this;
setTimeout(function() {
if (that.prevValue != $(that).val()) {
that.prevValue = $(that).val();
if ($(that).val().length == $(that).attr("maxlength")) {
$(that).nextAll("input")[0].focus();
}
}
});
});
问题是$(that).nextAll("input")[0]
返回未定义,而不是输入选择器,我无法使用focus()
它
任何想法这里发生了什么?谢谢