替代Jquery鼠标事件 [英] Alternative Jquery mouse event
本文介绍了替代Jquery鼠标事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
好吧,如果我在#nav div之外点击,下面的代码可以正常工作。我问是否可以将鼠标移离#nav div以使其消失。我不想'点击'来隐藏div。
Alright so the code below works fine if I click outside the #nav div. I was asking if it is possible to just move the mouse away from the #nav div to make it disappear. I don't want to 'click' to hide the div.
$(document).mouseup(function (e)
{
var container = $("#nav");
if (container.has(e.target).length === 0)
{
container.hide();
}
});
任何帮助将不胜感激:)
Any help will be appreciated :)
推荐答案
分配一个隐藏 mouseleave
事件元素的函数。
Assign a function that hides the element on the mouseleave
event.
$("#nav").mouseleave(function(){
$(this).hide();
});
小提琴: http://jsfiddle.net/howderek/SRMT8/
这篇关于替代Jquery鼠标事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文