作者robinnpca (rob)
看板Ajax
标题[问题] 进入父层才触发的mouseenter或mouseover
时间Wed Dec 14 22:41:45 2011
请教一个问题
若现在绑定mouse事件
在父层 但是希望子层能够不要触发事件
也就是不继承 可以用什麽方法或函数呢?
PS:目的就是进入父层时触发某一function
(最好能滑鼠继续在父层移动时 不断触发 如mousemove但是
在这里使用的话却连子层都会mousemove)
PS:不能用离开子层的事件如mouseout
因为子层可能很多都在隔壁
当从一个子层进入另外一个子层时
不需要触发该事件
例如
<div id="father" style="top:10px;left:10px;width:500px;height:500px">
<div id="child" style="position:relative;top:50px;left:50px;
width:100px;height:100px"></div>
</div>
$("#father").mouseenter(function(){
alert("out");
})
PS:
mouseenter变成只有从视窗外进入父或子层才会触发
mouseover会变成进出父层子层都会触发
mousemove会随便移动不论在哪 通通触发
focus好像是用在输入框所以没反应
请教如何达到
感谢!
--
宁愿天空是蓝色~
也不愿心情是蓝的!
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 118.233.4.14
※ 编辑: robinnpca 来自: 118.233.4.14 (12/14 22:43)
1F:→ gwokae:在function里面判断event的currentTarget? 12/15 00:04
2F:→ robinnpca:currentTarget我查了看不太懂..可以举例吗?感谢! 12/15 08:56
4F:→ robinnpca:感谢!范例了解了!可以得到绑定对象启发的mousemove座 12/17 11:51
5F:→ robinnpca:标~十分有用!再次感谢! 12/17 11:51