以下是我想要实现的内容:https://gfycat.com/ValidEmbarrassedHochstettersfrog
我想使用鼠标突出显示<table>
中的一些<td>
对象。这个视频是在Chrome上录制的,那里它可以完美地工作。不幸的是,在Firefox上无法正常工作。
以下是它的工作原理:
- 用户单击表格中的第一个单元格
- 他拖动鼠标到其他单元格
- 单元格被突出显示
代码如下:
$("#productList").on("mousedown", "td", function () {
//save from where to start
}
$("#productList").on("mouseover mouseenter mouseover hover", "td", function () {
//update highlighting, modify classes
//this function isn't fired when I click on one of <td> and drag mouse somewhere else
}
在此情况下,#productList
是一个 <table>
。
在Chrome浏览器中一切正常,但Firefox似乎无法触发mouseenter事件(以及我尝试的任何其他事件)。鼠标悬停只对我点击的对象有效。这似乎意味着在使用鼠标拖动时,Firefox仅考虑聚焦的对象。
我该如何绕过它?
编辑:
需要注意的一件重要事情是:每个单元格中都有一个<input>
。这可能会引起问题。
https://jsfiddle.net/q8v7f6uv/6/
user-select: text
。它与user-select: text
不起作用。还有其他解决方案吗? - Mr_Perfect