jQuery hover event won't fire the first time
By Drant on Wednesday 10 February 2010, - Technical - Permalink
Problem: jQuery won't fire when hovered over an element initially.
Example: For a menu with tabs or tooltips that fade in or pop up when a user hovers over, this bug prevents the binded effect from activating when the user hovers over the element for the first time. Such a menu tab would only effect after the user's mouse has entered, left, and entered the element's area again.
Cause: Event bubbling? Multiple nested elements?
Solution: Trigger a hover out event on the element programmatically (instead of by user interaction).
Add the following code after binding the hover function to that element:
$('ELEMENT').trigger('mouseout'); The
effects-binded element should now fires when mouseovered the first time.Keywords: JavaScript, onmouseout onmouseover mouseout mouseover mouseenter mouseleave, jQuery won't trigger, jQuery doesn't fire, hover over, the second time
Resources: trigger() function - jQuery API