<!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>
<style>
div {
width: 10px;
height: 10px;
background: red;
position: absolute;
}
</style>
<script>
window.onload = function() {
var aDiv = document.getElementsByTagName('div');
var i = 0;
document.onmousemove = function(ev) {
var oEvent = ev || event;
for (i = aDiv.length - 1; i > 0; i--) {
aDiv[i].style.left = aDiv[i - 1].style.left;
aDiv[i].style.top = aDiv[i - 1].style.top;
}
var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
var scrollLeft = document.documentElement.scrollLeft || document.body.scrollLeft;
aDiv[0].style.left = oEvent.clientX + scrollLeft + 'px';
aDiv[0].style.top = oEvent.clientY + scrollTop + 'px';
}
}
</script>
</head>
<body>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</body>
</html>