tags:

views:

23

answers:

1

Hi All,

I was wondering how I could reverse the click triggered in this function on 'mouseout' of 'a.menu-arrow'? See code below:

$(".menu-arrow").hover(function() {
  $.data(this, "timer", setTimeout($.proxy(function() {
    $(this).click();
  }, this), 500));
}, function() {
  clearTimeout($.data(this, "timer"));
});

What happens is after 0.5 of a second of hovering over a.menu-arrow...a click is triggered showing a adjacent div containing the submenu. This is how the HTML is structured unfortunately.

Any help would be greatly aprreciated.

Sorry I'm a novice at JavaScript & JQuery

A: 

In your code $(this).click() is not useful without a event handler function, to trigger an event virtually you need to use a .trigger() on an element, I believe you had a corresponding event handler function written before.

Ref : .trigger(), .data()

Ninja Dude
Sorry I implemented `.trigger('click');` but it did hide the adjacent submenu div when I mouseout of a.menu-arrow
Nasir
can u show your page? is it online ?
Ninja Dude
Sorry no ...unfortunately it the menus system of a intranet system I'm working on
Nasir
how about http://jsbin.com or http://jsfiddle.com ??
Ninja Dude
@Avinash - how can I write a similar function. Lets say on mouseover a.no-submenu ...if I've been hovering over this for 1 second ...then the next adjacent DIV is set to .hide();
Nasir
@Avinash...here it is on jsbin.com ( http://jsbin.com/eloxe3/3 )
Nasir
Ninja Dude