2021-08-23 鼠标跟随

<!DOCTYPE html>

<html lang=”en”>

<head>

  <meta charset=”UTF-8″>

  <title>Leon</title>

</head>

<body>

</body>

</html>

<script>

  // 鼠标跟随

  // 创建一个跟随的标签

  var sp = document.createElement( span );

  sp.innerText = Follow me all the time ;

  sp.style.position = absolute ;

  document.body.appendChild(sp);

  // 页面的鼠标必定事件

  document.onmousemove = function(e){

    e = e || window.event;

    // 将鼠标的定位给到sp标签

    sp.style.top = e.pageY + 10 + px ;

    sp.style.left = e.pageX + 20 + px ;

  }

</script>

© 版权声明
THE END
如果内容对您有所帮助,就支持一下吧!
点赞0 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容