做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")`
改成:
trigger("mouseenter")