Today I saw a place where I could drag the div to the page. Feel very good, on the whim of the query a bit, to see what netizens do
The code is as follows:
<script>
function doit () {
var obj = document.getElementById ("pad");
Obj.style.left = event.x+10;
Obj.style.top = event.y+10;
}
Window.onload=function () {
Document.body.onmousemove = doit;
}
</script>
<div id= "pad" style= "Padding:0px;margin:0px;width:10px;height:10px;left:0px;top:0px;background-color: #ff0000; position:absolute;z-index:100; " ></div>
This netizen says not to support ff!!
<script>
function doit (e) {
var obj = document.getElementById ("pad");
Obj.style.left = e.pagex+10;
Obj.style.top = e.pagey+10;
}
Window.onload=function () {document.body.onmousemove = doit (event);}
</script>
<div id= "pad" style= "Width:10px;height:10px;position:absolute" ></div>
JS Implementation div Follow mouse move