我正在使用以下代码使用 enter 键通过表单元素进行选项卡。问题是这段代码跳过了 select2 元素。 $('body').on('keydown', 'input, select', function(e) { if (e.key === "Enter") { var self = $(this), form = self.parents('form:eq(0)'), focusable, next; focusable = form.find('input,a,select,button,textarea').filter(':not([disabled]):not([tabindex="-1"]):visible'); next = focusable.eq(focusable.index(this)+1); if (next.length) { next.focus(); } else { //form.submit(); } return false; } });
1 回答

jeck猫
TA贡献1909条经验 获得超7个赞
改变你keydown
的keyup
$('body').on('keyup', 'input, select', function(e)
选择项目的原因keydown
已在select2
库中处理
添加回答
举报
0/150
提交
取消