我有一个上下文菜单,当你右键单击时,它会显示在某些元素上。这是没有问题的。
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();
});当用户没有悬停在菜单上时,我正在试图弄清楚如何隐藏菜单。现在,只要我在右击后移动鼠标,它就会淡出。
发布于 2012-04-07 07:54:27
事件最有可能是mouseleave,因为它是一个容器。
context_menu.mouseleave(function (e) {
$(this).fadeOut();
});发布于 2012-04-07 07:38:11
看这里:http://api.jquery.com/hover/
hover()事件有一个方法,用于判断鼠标何时停留在元素上,另一个方法用于判断鼠标何时不在元素上。
发布于 2012-04-07 10:53:24
$(selector).hover(handlerIn, handlerOut);
是以下的简写:
$(selector).mouseenter(handlerIn).mouseleave(handlerOut);https://stackoverflow.com/questions/10050301
复制相似问题