[英]How to capture hover event on selectize select box
I am am using Brian Reavis' excellent Selectize.js to add functionality to my select inputs. 我正在使用Brian Reavis出色的Selectize.js为我的选择输入添加功能。
But I am struggling to add an event handler when the user hovers their mouse above a selectized option. 但是当用户将鼠标悬停在选定选项上方时,我很难添加事件处理程序。 I can see no events documented in the API for this kind of event.
我看不到API中针对此类事件记录的事件。
I can see that selectize created its own divs like this 我可以看到selectize这样创建了自己的div
<div data-value="my value" data-selectable="" class="option">my label</div>
and that as I move my mouse over each option the class changes from 当我将鼠标移到每个选项上时,该类将从
class="option" to class="option active" and back again. 将class =“ option”更改为class =“ option active”,然后再次返回。
But I just cant see a way to add my own handler to these events. 但是我只是看不到将自己的处理程序添加到这些事件的方法。 Please can someone help.
请有人帮忙。
Many Thanks 非常感谢
Alec 亚历克
use the mouseenter
on the div inside .selectize-dropdown-content
使用
mouseenter
在DIV中.selectize-dropdown-content
$('.selectize-control').on('mouseenter', '.selectize-dropdown-content div', function() { alert($(this).text()) });
<link href="https://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.12.1/css/selectize.min.css" rel="stylesheet" /> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.12.1/js/standalone/selectize.min.js"></script> <div class="control-group"> <select id="select-beast" class="demo-default" placeholder="Select a person..."> <option value="">Select a person...</option> <option value="4">Thomas Edison</option> <option value="1">Nikola</option> <option value="3">Nikola Tesla</option> <option value="5">Arnold Schwarzenegger</option> </select> </div> <script> $('#select-beast').selectize({ maxItems: 3 }); </script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.