This JSFiddle显示了我的箭头键导航技巧。如何使用以下HTML跳过<br>
标记?
<div class='move'>
<input type="text" /><br>
<input type="text" /><br>
<input type="text" />
</div>
答案 0 :(得分:0)
<div class='move'><input /></div>
<div class='move'><input /></div>
<div class='move'><input /></div>
$(document).keydown(
function(e) {
if (e.keyCode == 39) {
$(".move>input:focus").parent().next().children().focus();
}
if (e.keyCode == 37) {
$(".move>input:focus").parent().prev().children().focus();
}
}
);
但我是这样做的:
$('.move>input').keydown(
function(e) {
if (e.keyCode == 39) {
$(this).parent().next().children().focus();
}
if (e.keyCode == 37) {
$(this).parent().prev().children().focus();
}
}
);