0
点赞
收藏
分享

微信扫一扫

select2 4.0.3 tab focus解决

知年_7740 2023-03-04 阅读 92


$(document).on("focus", ".select2", function (e) {
if (e.originalEvent) {
var s2element = $(this).siblings("select:enabled");
s2element.select2("open");
// Set focus back to select2 element on closing.
s2element.on("select2:closing", function () {
if (s2element.val()) s2element.select2("focus");
});
}
});

如果出现多选选择异常的话
补充一下:

$(document).on("focus", ".select2", function (e) {
if (e.originalEvent) {
var s2element = $(this).siblings("select:enabled");
s2element.select2("open");
// Set focus back to select2 element on closing.
s2element.on("select2:closing", function () {
if (s2element.val()) s2element.select2("focus");
});
}
});

举报

相关推荐

0 条评论