<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
img
{
position: absolute;
top: 2px;
}
</style>
</head>
<body>
<img src="img/1.jpg" alt="">
<script>
var pic = document.querySelector('img');
document.addEventListener('mouseleave',function(e)
{
var x = e.pageX;
var y = e.pageY;
console.log('x坐标' + x, 'y坐标' + y);
pic.style.left = x + 'px';
pic.style.left = y + 'px';
});
</script>
</body>
</html>
随便一张图片<img src="img/1.jpg" alt="">
mouseleave 只要我们鼠标移动1px 就会触发这个事件
document.addEventListener('mouseleave',function(e)