Tag: Turn scrollto tle offset FSE Elements CharSet utf-8 function
<! DOCTYPE html>
<meta charset= "UTF-8" >
<title></title>
<style>
div{
width:10px;
height:10px;
margin:5px;
Position:absolute;
}
</style>
<script>
function GetPos (EV) {
var rolltop = Document.documentElement.scrollTop | | Document.body.scrollTop;
var rollleft = Document.documentElement.scrollLeft | | Document.body.scrollLeft;
Returns a JSON
return {x:ev.clientx + rollleft, Y:ev.clienty + rolltop};
}
Document.onmousemove = function (EV) {
var alldiv = document.getelementsbytagname (' div ');
var oevent = ev| | Event
var pos = GetPos (oevent);
for (Var i=alldiv.length-1;i>0;i--) {
The position of the latter div is equal to the position of the previous Div
Alldiv[i].style.left = alldiv[i-1].offsetleft + ' px ';
Alldiv[i].style.top = alldiv[i-1].offsettop + ' px ';
}
Set the left of the first div to the position of the mouse
Alldiv[0].style.left = pos.x + ' px ';
Alldiv[0].style.top = pos.y + ' px ';
};
</script>
<body>
<div></div>
<div></div>
<div></div>
<div>L</div>
<div>o</div>
<div>v</div>
<div>e</div>
<div></div>
<div>h</div>
<div></div>
<div>u</div>
<div></div>
<div>x</div>
<div></div>
<div>i</div>
<div></div>
<div>a</div>
<div></div>
<div>o</div>
<div></div>
<div>w</div>
<div></div>
<div>e</div>
<div></div>
<div>n</div>
<div></div>
<div>h</div>
<div></div>
<div>u</div>
<div></div>
<div>x</div>
<div></div>
<div>i</div>
<div></div>
<div>a</div>
<div></div>
<div>o</div>
<div></div>
<div>w</div>
<div></div>
<div>e</div>
<div></div>
<div>n</div>
<div></div>
</body>
A div that follows the mouse movement