使用select2激活悬停/鼠标悬停时的选择菜单 [英] activate select menu on hover/mouseover using select2

查看:61
本文介绍了使用select2激活悬停/鼠标悬停时的选择菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在查看文档以尝试找到一种方法来轻松激活 hover 上的选择菜单,而不仅仅是点击

I've been looking around the documentation to try find a way to easily activate the select menu on hover, and not only on click.

不幸的是,我似乎找不到办法(如果它存在),并希望有人可以指出我在右边方向?

Unfortunately, I cannot seem to find the way to do it (if it exists), and was hoping someone could point me in the right direction?

这是一个plnk,

http://plnkr.co/edit/GTeyWfOp9aTd1B0Be0Hs?p=preview

全部谢谢

推荐答案

试试这个:

$("#myselect").next(".select2").mouseenter(function() {
    $("#myselect").select2("open");
});
$(document).on("mouseleave", ".select2-container", function(e) {
    if ($(e.toElement || e.relatedTarget).closest(".select2-container").length == 0) {
        $("#myselect").select2("close");
    }    
});

这篇关于使用select2激活悬停/鼠标悬停时的选择菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆