当鼠标光标悬停在不同的页面元素上时,是否会触发任何事件?
理想的情况是这样的:
window.onmousecursorchange = function(e) {
// e would contain information about the cursor
// eg. e.type could contain 'text','pointer', etc..
}
- 注意:解决方案不应涉及jQuery或其他库**
- 更新**:
"可能重复"的问题是用jQuery标记的,事实上所有的答案(没有一个能解决这个问题)都是基于jQuery的。我正在寻找一个纯粹的JavaScript解决方案。如果主持人认为这不是保持这个问题开放的足够理由,请随时关闭。
4条答案
按热度按时间ndasle7k1#
是,事件
onmouseenter
cbjzeqam2#
你可以试试这个:
它使用事件冒泡来提高性能并节省代码。
izkcnapc3#
yc0p9oo04#
@Lickson的解决方案here只适用于内联样式,不适用于css文件中定义的游标。因此,您需要
getComputedStyle