使用JavaScript事件模拟悬停 [英] Simulate hover using JavaScript events

查看:149
本文介绍了使用JavaScript事件模拟悬停的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以使用JavaScript事件模拟悬停吗?我试图在目标元素上注入mouseover事件,但没有运气。

Is it possible to simulate hover using JavaScript Events? I tried injecting mouseover event on the target element but no luck.

例如,如果有一个具有悬浮选择器的链接,是否可以使用JavaScript事件悬停?基本上我想触发CSS悬停。你可以假设我不能使用jQuery。

For example, if there is a link that has a hover selector, is it possible to "hover" over it using JavaScript Events? Basically, I want to trigger CSS hover. You can assume I can't use jQuery.

推荐答案

jQuery hover事件只是使用 mouseenter mouseleave 事件。这是jQuery的悬停源:

The jQuery hover event is just using mouseenter and mouseleave events. Here is the source of jQuery's hover:

function (fnOver, fnOut) {
    return this.mouseenter(fnOver).mouseleave(fnOut || fnOver);
}

这篇关于使用JavaScript事件模拟悬停的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆