Fire css: hover event with js
Instead of doing it this way, I suggest you just add the class to another tag. In jQuery, this will be:
$(window).load(function() { $('.trigger-animate').hover(function(){ $('.animate').addClass('hover'); }); } I would recommend using this method because it handles both onMouseOver and onMouseOut (this way you can also remove the class when your mouse leaves $ ('. Trigger-animate') if you want to use this syntax:
.hover( handlerIn(eventObject), handlerOut(eventObject) ) checking out the documentation As described in the css hang with JS , this is not possible as-is (if you want it to be described exactly while creating this answer).
But the main goal is achievable:
- Setting the
hoverclass (or any other name), as well as the:hoverselector in CSS. - Call
.addClass("hover")to launch CSS and.trigger("hover")or.trigger("mouseenter")to launch JS. - Providing a
mouseleavehandler. or 2.hover(), clears thehoverclass, if any.