js 方块跟随鼠标移动
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
.app{
width:100px;
height:100px;
background-color: red;
}
</style>
</head>
<body>
<div class="app" style="position: absolute;left:0px;top:0px"></div>
<script>
var div = document.getElementsByTagName('div')[0];
document.onmousemove = function(e){
var event = e || window.event
div.style.left = e.pageX + 'px'
div.style.top = e.pageY + 'px'
}
</script>
</body>
</html>