Ich habe folgendes html:
<div>
<input type="text" maxlength="2" class="day-spin-month"></input>
<span>/</span>
<input type="text" maxlength="2" class="day-spin-day"></input>
<span>/</span>
<input type="text" maxlength="4" class="day-spin-year"></input>
</div>
Ich versuche, den Fokus auf die nächste Eingabe zu ändern. Ich habe es auf die folgenden 2 Arten funktioniert.
$('.day-spin-month').on('keyup', function () {
if (this.value.length >= 2) {
$(this).next().next().focus();
}
});
$('.day-spin-day').on('keyup', function () {
if (this.value.length >= 2) {
$(this).next().next().focus();
}
});
Geige: http://jsfiddle.net/dan_vitch/JbQaN/1/
$('.day-spin-month').on('keyup', function () {
if (this.value.length >= 2) {
var test=$(this).next()
var test2= $(test).next('input');
test2.focus();
}
});
$('.day-spin-day').on('keyup', function () {
if (this.value.length >= 2) {
var test=$(this).next()
var test2= $(test).next('input');
test2.focus();
}
});
Geige: http://jsfiddle.net/dan_vitch/JbQaN/2/
aber so geht das nicht:
$('.day-spin-month').on('keyup', function () {
if (this.value.length >= 2) {
$(this).next('input').focus();
}
});
$('.day-spin-day').on('keyup', function () {
if (this.value.length >= 2) {
$(this).next('input').focus();
}
});
Geige: http://jsfiddle.net/dan_vitch/rJwyE/2/
Ich möchte den Weg verwenden, der nicht funktioniert. Ich bin mir nicht sicher, ob mein Selektor so falsch ist oder wie ich next verstehe ()
stackoverflow.com/questions/290535/…
– Morten Anderson
12. Dezember 2011 um 23:11 Uhr