views:

73

answers:

3

I am trying to activate the native hover effect of a div from another div. I understand that I could do this all in jQuery and add the styles in there, but would rather leave the native :hover in the CSS. I'm just wondering if there is a way for this to work:

$("#div1").live("mouseenter", function() {
  $("#div2").trigger("mouseenter");
});

I'd like to call it by doing something like this, but it isn't working. Is there really no way to trigger an event from another element's event?

Thanks in advance.

A: 

I believe it is

$("#div1").live("mouseenter", function() {
  $("#div2").mouseenter();
});
j.
No luck :( I think that event takes arguments
jakeprzespo
@jakeprzespo: When `jQuery#mouseenter()` is used without arguments, it’s an alias for `jQuery#trigger('mouseenter')`.
Mathias Bynens
@jakeprzespo: not necessarily.
j.
Oh, ok. Will keep that in mind. Still isn't triggering correctly however.
jakeprzespo
A: 

This should work?

$("#div1").mouseenter(function() {
  $("#div2").mouseenter();
});
baloo
Live binds the events staticly to content even if the content is being changed (ajax)
Jaroslav Moravec
A: 

This have been answered here

according to the W3C's spec, the :hover pseudo-class should only be applied when the user initiates the action.

The :hover pseudo-class applies while the user designates an element (with some pointing device), but does not activate it. For example, a visual user agent could apply this pseudo-class when the cursor (mouse pointer) hovers over a box generated by the element. User agents not supporting interactive media do not have to support this pseudo-class.

JHurrah