April 6, 2012
What event should I use to hide context menu in jquery?
Question by Frankie
I have a contextmenu that shows on certain elements when you right click. This works no problem.
wrapper.on('contextmenu', 'div.outer', function (e) {
context_menu.css({
left: e.pageX,
top: e.pageY,
zIndex: '101'
}).fadeIn();
return false;
});
//This does not work correctly
context_menu.mouseout(function (e) {
$(this).fadeOut();
});
I’m trying to figure out how to hide the menu when the user is not hovered over the menu. Right now as soon as I move the mouse after I right click it fades out.
Answer by Starx
The events, should most probably be mouseleave
since its a container.
context_menu.mouseleave(function (e) {
$(this).fadeOut();
});