使用select2激活hover/鼠标hover时的选择菜单

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

不幸的是,我似乎无法找到方法(如果它存在),并希望有人能指出我正确的方向?

这是一个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"); } }); 

我在mouseenter和mouseleave上打开和关闭select2的通用解决方案

 $(document).on('mouseenter', '.select2-container', function(e) { $(this).prev("select").select2("open"); }); $(document).on('mouseleave', '.select2-container .select2-dropdown', function(e) { var selectId = $(this).find("ul").attr('id').replace("select2-", "").replace("-results", ""); $("#"+selectId).select2("close"); });