Demo效果如下:

完整代码如下:
<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta http-equiv="X-UA-Compatible" content="ie=edge"><title>Document</title><script src="./lib/jquery.js"></script><style>html,body {margin: 0;padding: 0;overflow: hidden;}#angel {position: absolute;}</style>
</head><body><img src="https://profile.csdnimg.cn/3/8/1/3_weixin_49918657" alt="" id="angel" /> // 使用任意本地或在线图片<script>$(function () {// 1. 获取到图片var angel = $('#angel')// 步骤1. 定义节流阀var timer = null// 2. 绑定 mousemove 事件$(document).on('mousemove', function (e) {// 步骤3:判断节流阀是否为空if (timer) { return }// 3. 设置图片的位置// 步骤2:开启延时器timer = setTimeout(function () {$(angel).css('top', e.pageY-50 + 'px').css('left', e.pageX-40 + 'px')console.log('ok')timer = null}, 16)})})</script>
</body></html>















