日日行,不怕千万里

javascript --- 鼠标事件

1、基本鼠标事件:

mouseenter:当鼠标移入某元素时触发。

mouseleave:当鼠标移出某元素时触发。

mouseover:当鼠标移入某元素时触发,移入和移出其子元素时也会触发。

mouseout:当鼠标移出某元素时触发,移入和移出其子元素时也会触发。

mousemove:鼠标在某元素上移动时触发,即使在其子元素上也会触发。

2、基本鼠标事件操作:

var body = document.querySelector("body");

body.onmouseenter = (e) => { alert(1111) };

body.onmouseleave = (e) => { alert(2222) };

body.onmouseover  = (e) => { alert(3333) };

body.onmouseout   = (e) => { alert(4444) };

body.onmousemove = (e)  => { alert(5555) };

posted @ 2017-11-04 21:40  GongXiaoZhu  阅读(215)  评论(0编辑  收藏  举报