我想在鼠标移出一个div时候触发一个事件,而事实上onmouseout在鼠标移到这个div里面的html控件也触发了该事件,下面是我的测试代码:$(document).ready(function(){
$("#tdiv").mouseout(function(){
alert("y");
});
});
<div id="tdiv" STYLE="border-style:solid;border-width:5pt; border-color:black; height:180px;">
<input type="text"/> <br>
<input type="button"/> <br>
<span>aaaaaaaa</span><br>
</div>
当鼠标还在这个div中的时候,鼠标经过div里面的文本框,按钮跟span都触发了mouseout事件,该怎么解决这个问题???
$("#tdiv").mouseout(function(){
alert("y");
});
});
<div id="tdiv" STYLE="border-style:solid;border-width:5pt; border-color:black; height:180px;">
<input type="text"/> <br>
<input type="button"/> <br>
<span>aaaaaaaa</span><br>
</div>
当鼠标还在这个div中的时候,鼠标经过div里面的文本框,按钮跟span都触发了mouseout事件,该怎么解决这个问题???
解决方案 »
- 为什么大多数网页都用js脚本而不用vbs呢?
- 如何把文本框中的html的特殊字符转换了啊?
- 写一个简单javascript菜单,百分送上
- 帮看下下边的代码为什么第一次时要双击右键才出来contextmenu?
- 高手来:javascript如果根据中文取拼音首字母
- 关于firefox 中window.returnValue的提示,以及其他几个问题!
- 急了,救命啊,关于网页real控件的问题.
- 如何在前端控制只能输入数字和小数点?
- insertRow(),控制tr背景色
- ?见了好几次<object id="WebBrowser"...></object>,哪位大侠给咱介绍介绍这个对象?
- 对象数组的问题
- 如何在加载事件中同时实现多个函数?
$("#tdiv").mouseout(function(){
alert("y");
return false;
});
});
{
HTMLElement.prototype.contains = function(obj)
{
while(obj != null && typeof(obj.tagName) != "undefined")
{
if(obj == this)
return true;
obj = obj.parentNode;
}
return false;
};
} div.onmouseout=function(e){
e = e||event;
e = e.toElement || e.relatedTarget ; // 目标元素 IE toElement FF:relatedTarget
if(typeof(e)!="undefined" &&!this.contains(e)){ //目标 非子元素
// 此次执行 mouseout 代码
alert("mouseout");
}
};