Adding a hover trigger from another div

I am trying to activate a div's own hover effect on another div. I realize that I could do all of this in jQuery and add styles there, but would prefer to keep it native :hover

in CSS. I'm just wondering if there is a way to do this:

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

      

I would like to call it by doing something like this, but it doesn't work. Is there no way to trigger an event from another item event?

Thanks in advance.

+2


a source to share


3 answers


I believe it is



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

      

0


a source


Should this work?



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

      

0


a source


This has been answered here

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

The hover pseudo-class is applied while the user is indicating the element (with some pointing devices), but do not activate it. For example, a visual user agent can apply this pseudo-class when the cursor (mouse pointer) hovers over a field generated by an element. User agents that do not support interactive media should not support this pseudo-class.

0


a source







All Articles