JS---案例:图标跟着鼠标飞(有bug)

案例:图标跟着鼠标飞(有bug)

 

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <title>title</title>
  <style>
    img {
      position: absolute;
    }
  </style>
</head>

<body>
  <img src="images/tianshi.gif" alt="" id="im">
  <script src="common.js"></script>
  <script>
    //鼠标在页面中移动,图片跟着鼠标移动
    document.onmousemove = function (e) {
      //鼠标的移动的横纵坐标
      //可视区域的横坐标
      //可视区域的纵坐标
      my$("im").style.left = e.clientX + "px";
      my$("im").style.top = e.clientY + "px";
    };

  </script>
</body>

</html>
posted @ 2019-12-13 13:12  jane_panyiyun  阅读(394)  评论(0编辑  收藏  举报