0
我有一個包含一些輸入的表單。我想通過輸入鍵移動這些表單。我怎樣才能通過使用jQuery?從上輸入,然後切換方式提交的打算關閉如何通過輸入鍵在jQuery中移動窗體中的所有輸入?
我有一個包含一些輸入的表單。我想通過輸入鍵移動這些表單。我怎樣才能通過使用jQuery?從上輸入,然後切換方式提交的打算關閉如何通過輸入鍵在jQuery中移動窗體中的所有輸入?
停止形式進入
$('form').keydown(function (e) {
if (e.which === 13) {
e.preventDefault();
}
});
$('.inputs').keydown(function (e) {
if (e.which === 13) {
var index = $('.inputs').index(this) + 1;
$('.inputs').eq(index).focus();
}
});
$("input").bind("keydown", function(event) {
if (event.which === 13) {
$(this).next("input").focus();
}
});
爲什麼不到風度的工作給我嗎? – Motion
請查看https://jsfiddle.net/pmajhwar/zgu9rLxs/ –
雖然此代碼可能會回答問題,但提供有關* how *和/或* why *解決問題的其他上下文會提高答案的長期價值。 –