mousedown和光标事件未触发

时间:2015-02-05 13:58:13

标签: jquery mouseevent internet-explorer-10 internet-explorer-11

在这些情况下,我使用鼠标按下和鼠标按下jQuery事件来更改我的光标。这似乎适用于除IE 10和11之外的所有浏览器。我无法找到任何可以说明为什么不能工作或替代这些事件的资源。有什么帮助吗?

$("#element").mousedown(function(){
     $(this).css("cursor" , "move");
}).mouseup(function(){
     $(this).css("cursor" , "default");
});

1 个答案:

答案 0 :(得分:0)

我在IE 11中使用了以下标记,它按预期工作:

  $(function () {
    $("#div1").mousedown(function () {
      $(this).css("cursor", "move");
    }).mouseup(function () {
      $(this).css("cursor", "default");
    });
  });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="container body-content">
  <div id="div1" style="width: 100px; height: 100px; background-color: red;">
    &nbsp;
  </div>
</div>

确保事件附加到元素?