码迷,mamicode.com
首页 > Web开发 > 详细

2015-06-02 js中的mouseover,mouseenter,mousemove的区别

时间:2015-06-02 17:24:26      阅读:135      评论:0      收藏:0      [点我收藏+]

标签:

<ul id="test">
  <li>item 1</li>
  <li>item 2</li>
  <li>item 3</li>
</ul>

<script>
  var test = document.getElementById("test");
  
  
  // this handler will be executed only once when the cursor moves over the unordered list
  test.addEventListener("mouseenter", function( event ) {   
    // highlight the mouseenter target
    event.target.style.color = "purple";

    // reset the color after a short delay
    setTimeout(function() {
      event.target.style.color = "";
    }, 500);
  }, false);
  
  
  // this handler will be executed every time the cursor is moved over a different list item
  test.addEventListener("mouseover", function( event ) {   
    // highlight the mouseover target
    event.target.style.color = "orange";

    // reset the color after a short delay
    setTimeout(function() {
      event.target.style.color = "";
    }, 500);
  }, false);
</script>

for mousemove,it means event opened when moved in element.

  

 

2015-06-02 js中的mouseover,mouseenter,mousemove的区别

标签:

原文地址:http://www.cnblogs.com/wz0107/p/4546594.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!