我試圖做猜謎這樣的填字遊戲,當輸入字段爲字母時,需要改變輸入焦點。問題是,我可以改變重點是在同一個div的div輸入焦點變化
$(':input').keyup(function (e) {
if ($(this).val().length == $(this).attr('maxlength')) {
$(this).closest('div').next().find(':input').first().focus();
}
})
$(".inputs").keyup(function() {
$(this).next().focus();
});
之間或兩個領域,但我不知道如何改變專注於下一個輸入沒關係,如果它是在相同的div或它在另一個div中。
<div class="answer_1">
<input class="inputs letter square border_orange" maxlength="1" type="text" />
<input class="inputs letter square border_orange" maxlength="1" type="text" />
</div>
<div class="answer_2">
<input class="inputs letter square border_orange" maxlength="1" type="text" />
<input class="inputs letter square border_orange" maxlength="1" type="text" />
</div>
HTML代碼以上,我試圖在ANSWER_1 DIV第一改變輸入焦點內的輸入,並且當我與第二輸入這裏完成,以全自動在下一DIV改變焦點上輸入。 有什麼建議嗎?
這是很好的解決方案。謝啦。 –