只有在移动鼠标后,jQuery click事件才有效,而CSS悬停处于打开状态(当悬停关闭时按预期工作)

时间:2017-03-30 13:03:54

标签: jquery css macos onclick hover

我遇到了同样的问题: jQuery click event only working after moving the mouse in Chrome,但仅限于Mac,OS X(我查看了Chrome,Firefox和Safari)。它在Windows上按预期工作(我忽略了IE)。

这是我的小提琴,细胞在悬停时会变暗,并在点击(意图)时改变颜色,但mac上的颜色变化只有在您移动鼠标后才会发生(无意识):{{3 }}

现在,当我评论悬停时,它工作正常 - 点击时颜色会立即改变。那么CSS悬停和jQuery点击不能在mac上一起工作的问题呢?它是什么?

td:not(.main):hover {
    background: #cccccc;
    background: linear-gradient(to bottom right, #cccccc, #a6a6a6);
}

1 个答案:

答案 0 :(得分:0)

尝试添加"!important"在你的一些css规则中:

#yes, td.yes {
  background: green !important;
  background: linear-gradient(to top right, green, yellowgreen) !important;
}

#no, td.no {
  background: red !important;
  background: linear-gradient(to bottom right, red, maroon) !important;
}

(好的,我有我的mac方便!)

在这里小提琴:https://jsfiddle.net/s8c7qm7g/

希望这就是你要找的东西。