2

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.

jakeprzespo
  • 333
  • 1
  • 4
  • 6

3 Answers3

0

I believe it is

$("#div1").live("mouseenter", function() {
  $("#div2").mouseenter();
});
Ju Nogueira
  • 8,435
  • 2
  • 29
  • 33
0

This should work?

$("#div1").mouseenter(function() {
  $("#div2").mouseenter();
});
baloo
  • 7,635
  • 4
  • 27
  • 35
0

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.

Community
  • 1
  • 1
JHurrah
  • 1,988
  • 16
  • 12