一:onmouseover、onmouseout:
鼠标经过时自身触发事件,经过其子元素时也触发该事件;(父亲有的东西,儿子也有)
二:onmouseenter、onmouseleave:
鼠标经过时自身触发事件,经过其子元素时不触发该事件。(父亲的东西就是父亲的,不归儿子所有)
三:onmousemove :当鼠标移动的时候 常用语canvas 绘制
这四个事件两两配对使用,onmouseover、onmouseout一对,onmouseenter、onmouseleave一对,不能混合使用。
例如:当做商城导航栏,需要鼠标移动到子元素(例如:商品名)上,然后显示父元素的另一个子元素(例如:商品详情)
此时:用onmouseover =》示例: 将Img 放大
<!DOCTYPE html><html><head><script>function myFunction(e){x=e.clientX;y=e.clientY;coor="Coordinates: (" + x + "," + y + ")";document.getElementById("demo").innerHTML=coor}function clearCoor(){document.getElementById("demo").innerHTML="";}</script></head><body style="margin:0px;"><div id="coordiv" style="width:199px;height:99px;border:1px solid"onmousemove="myFunction(event)" onmouseout="clearCoor()"></div><p>Mouse over the rectangle above, and get the coordinates of your mouse pointer.</p><p id="demo"></p></body></html>JS事件:onmouseover onmouseout &&onmouseenter onmouseleave &&onmousemove的区别
原文:http://www.cnblogs.com/ccnNL/p/7707618.html