私はこの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()
ないことです
ここで何が起こっているのかアイデアはありますか?ありがとう