mouseenter事件在Internet Explorer中无效

时间:2016-01-14 18:41:56

标签: jquery internet-explorer

我有这个代码似乎在IE中不起作用。我有IE 11工作,我无法启动它。所有其他浏览器都很好。我做错了什么,或者IE有更好的方法。

<select class="form-control" name="travail" data-title='Refresh for new     questions' size="10">
  <option>category</option>
  <option value="Description technique" data-id="72">soemthing else</option>
  <option value="Plan topographique" data-id="77">soemthing</option>
  <option value="Nivellement" data-id="78">some</option>
  <option value="Plan projet d'ensemble" data-id="76">thing</option>
  <option value="Méthode BOMA" data-id="77">else</option>
  <option value="Volumétrie" data-id="78">example</option>
</select>


$('select[name="travail"]').on('mouseenter', 'option', function(e) {
  console.log($(this).attr('data-id'));
  //this is originally an ajax call, but it doesn't get fired in IE
});

fiddle

1 个答案:

答案 0 :(得分:0)

尝试将JS更改为

$('select[name="travail"]').mouseenter(function(e) {
  console.log('over');
  //this is originally an ajax call, but it doesn't get fired in IE
});

我认为它应该在我测试它时起作用。

关键部分正在发生变化 obj.on('mouseenter'...) obj.mouseenter(...)