由于hover
事件是TrustedEvent,因此扭转它,尝试对其进行模拟等有点复杂。
我正在寻找一种方法来检测元素悬停时元素的样式属性是否正在更改。
这是一个可以说明基本情况的代码段。
.change-when-hovering:hover {
color: blue;
}
<p>
It won't have any style changes, we don't want to console.log the element when hovering
</p>
<p class="change-when-hovering">
It will have style changes, we want to console.log this element when hovering BECAUSE his style properties has changed (and not because he has the 'change-when-hovering' class)
</p>
谢谢!