我有一个jsp页面,我想在页面中实现上下左右键功能。我有以下代码,但它也访问只读文本框。我想跳过那个只读输入。请检查随附的快照。我有 A、B、C、D、E、F、G、H 输入,但 E 和 F 是只读的。我的光标在 C 上。假设如果我按下键(代码 = 40),那么它应该通过跳过 E 和 F 转到 G。与其他键相同。请检查此链接以获取图像:
https://www.dropbox.com/s/ptm483avp8pm9sg/Untitled.png?dl=0
$(document).ready(function(){
$("input,textarea").keydown(function(e) {
if (e.keyCode==37 || e.keyCode==38 ) {
$(":input,textarea,select")[$(":input,select").index(document.activeElement) - 1].focus();
}
if (e.keyCode==39 || e.keyCode==40 ) {
$(":input,textarea,select")[$(":input,select").index(document.activeElement) + 1 ].focus();
}
});
});