猿问

使用Jquery同时判断两个DIV事件

使用jQuery判断鼠标同时移出了 DIV1和DIV2 然后触发alert('abc'); 事件!

如何实现


米脂
浏览 823回答 1
1回答

小怪兽爱吃肉

1.把两个div放在同一个div上,在div3添加鼠标移出事件。<div class='div3'>&nbsp; &nbsp; <div class="div1"></div>&nbsp; &nbsp; <div class="div2"></div></div>2.如果鼠标从div1或者div2出来了,0.5秒内鼠标没进入div1或者div2的话,触发方法。0.5秒内进入了,就清楚定时器,不触发方法!var timer=null;odvi1.onmouseover=odvi2.onmouseover=function () {&nbsp; &nbsp; clearTimeout(timer);}odvi1.onmouseout=odvi2.onmouseout=function () {&nbsp; &nbsp; timer=setTimeout(function () {&nbsp; &nbsp; &nbsp; &nbsp; alert("abc");&nbsp; &nbsp; },500)}
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答