获取jQuery的mouseout事件,从所有子元素火
-
06-09-2019 - |
题
我有一个表处在div中,含8个图像,我想火mouseOut事件为任一表或在div,但它不触发。我猜这是因为鼠标实际上是让每一个图像,或者TD,或TR等...有没有办法让鼠标移开事件使得它甚至被解雇整个表传播起来从子元素?标记是直截了当:
<div id=container>
<table id="tbl">
<tr>
<td><img src=""></td>
<td><img src=""></td>
<td><img src=""></td>
<td><img src=""></td>
</tr>
<tr>
<td><img src=""></td>
<td><img src=""></td>
<td><img src=""></td>
<td><img src=""></td>
</tr>
</table>
</div>
和我的jQuery代码是:
$("#tbl").mouseout(function(){
alert("out home");
});
我不能火的图像中的个体的mouseout事件,因为有绝对有时放置元件在它们导致mouseout事件过早烧制。
没有正确的解决方案
其他提示
应该是:
$("#tbl").mouseout(function(){
alert("out home");
});
您已经错过了 “#”。 如果你想只图像,请尝试:
$("#tbl >img").mouseout(function(){
alert("out home");
});
PS。你有没有考虑使用$( “...”)。悬停(),而不是?
你不应该使用#tbl选择表?
$("#tbl").mouseout(function(){
alert("out home");
});
使用mouseleave
事件,其中有完全相同的功能,但它不与子元素火。
$("#tbl").bind("mouseleave",function(){
alert("out home");
});
不隶属于 StackOverflow