300字范文,内容丰富有趣,生活中的好帮手!
300字范文 > html中hover无法触发 jQuery中trigger无法触发hover事件解决方法

html中hover无法触发 jQuery中trigger无法触发hover事件解决方法

时间:2021-06-21 09:20:50

相关推荐

html中hover无法触发 jQuery中trigger无法触发hover事件解决方法

做jquery练习的时候需要在外部触发元素的”hover”事件,于是,问题来了:根本没有触发,无论是trigger( )还是triggerHandler( ),查询后得知:

Deprecated in jQuery 1.8, removed in 1.9: The name “hover” used as a shorthand for the string “mouseenter mouseleave”. It attaches a single event handler for those two events, and the handler must examine event.type to determine whether the event is mouseenter or mouseleave. Do not confuse the “hover” pseudo-event-name with the .hover() method, which accepts one or two functions.

如果要触发”hover”事件,实际上是触发了”mouseenter”或者”mouseleave”时间,所以,

trigger("hover")`

改成:

triiger("mouseenter")

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。