使用jquery获取引导选择选项的值

使用jquery获取引导选择选项的值,jquery,select,mousehover,Jquery,Select,Mousehover,我编写了这个Html,并使用Bootstrap select创建jquery select <select id="type" class="selectpicker"> <option>Select...</option> <option value="1">1</option> <option value="2">2</option> 将使用类bootstrap select包装在容器中,因

我编写了这个Html,并使用Bootstrap select创建jquery select

<select id="type" class="selectpicker">
        <option>Select...</option>
<option value="1">1</option>
<option value="2">2</option>
将使用类bootstrap select包装在容器中,因此在初始化插件后,可以执行以下操作:

  $('.bootstrap-select').on('mouseenter', function(e){
     console.log($(this).find('select').val())
  })
或者您可以在初始化插件之前委派侦听器

  $(document).on('mouseenter','.bootstrap-select', function(e){
     console.log($(this).find('select').val())
  })    

什么是引导选择?此解决方案仅在我用鼠标输入选择时显示初始值。但当我按下它,开始在选项中移动时,什么都没有发生。那是因为你用鼠标。我明白这一点。我把它改为mouseover,现在在浏览选项时,我得到了很多日志。问题是我没有得到正确的值,因为这个选择是以一种复杂的方式构造的。我将为此更新我的问题。我自己解决了,并用解决方案更新了问题。顺便说一下,把你的答案标记为解决方案。你指明了正确的道路。谢谢
  $('.bootstrap-select').on('mouseenter', function(e){
     console.log($(this).find('select').val())
  })
  $(document).on('mouseenter','.bootstrap-select', function(e){
     console.log($(this).find('select').val())
  })