【问题标题】:jQuery moving element highlights table cells in FirefoxjQuery 移动元素突出显示 Firefox 中的表格单元格
【发布时间】:2014-06-03 05:44:47
【问题描述】:

我有以下代码:

// Drag Event
var _isMoving = false;
$("body").on("mousedown", ".k-event", function () {
    _isMoving = true;
});

// This is here because otherwise the mouse will try and select the grid and looks really ugly
$("body").mousemove(function (e) {
    if (_isMoving)
        e.preventDefault();
});

$("body").mouseup(function () {
    _isMoving = false;
});

在 Chrome 上,这很好用。

但是,在 Firefox 上,当我尝试在按下鼠标按钮的情况下移动鼠标时,它仍然希望突出显示表格单元格(就像我在尝试复制/粘贴某些内容一样)。如何告诉 Firefox 不要尝试突出显示任何内容?

【问题讨论】:

  • $("body").on("mousedown", ".k-event", function (e) { e.preventDefault(); _isMoving = true; }
  • 成功了。作为答案发布,我会给予信任。
  • (OT) P.S.我相信你知道你错过了两次);! :) 只是注意并指出可能会查看您的代码的新手程序员;)
  • 修改代码以修复这些错误。不错的收获,Roko!

标签: jquery highlighting mousedown


【解决方案1】:

对于 Firefox,您还应该在 mousedown 事件上阻止该事件:

$("body").on("mousedown", ".k-event", function (e) { 
  e.preventDefault(); 
  _isMoving = true; 
} 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-03-12
    • 1970-01-01
    • 2016-08-07
    • 2015-11-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多