Trigger css hover with JS

javascript, jquery

Solution

I know what you're trying to do, but why not simply do this:

$('div').addClass('hover');

The class is already defined in your CSS...

As for you original question, this has been asked before and it is not possible unfortunately. e.g. http://forum.jquery.com/topic/jquery-triggering-css-pseudo-selectors-like-hover

However, your desired functionality may be possible if your Stylesheet is defined in Javascript. see: http://www.4pmp.com/2009/11/dynamic-css-pseudo-class-styles-with-jquery/

Hope this helps!

Problem

I would know if it is possible somehow to trigger the CSS HOVER effect with JS, without having to use a additional class... Here is an example of what i want to do: http://jsfiddle.net/pXbMZ/2/ i have tried fireing the effect using `mouseenter()` but this does not trigger the CSS hover effect. PS: I have made a function that helps a user using a online CMS. The help function shows you how to do stuff by moving a image around that shows you how to use stuff. The virtual cursor can click stuff, show elements etc.. But i would like this virtual cursor to tigger the :hover effects set in the CSS as well.

Original source

Related problems