<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
img{position: abso
lute;}
</style>
</head>
<body>
<img src="滑稽.webp" >
<script type="text/javascript">
let img = document.querySelector('img') //获取img标签
// console.log(img)
document.addEventListener('mousemove',function(e){ //悬浮时
let x = e.clientX //获取x轴
let y = e.clientY //获取y轴
img.style.top = y + 'px' //添加样式
img.style.left = x + 'px' //添加样式
})
</script>
</body>
</html>