我正在使用以下代码使用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;
}
});
将keydown
更改为keyup
$('body').on('keyup', 'input, select', function(e)
原因是keydown
已在select2
库中用于选择项目的处理