Home >Web Front-end >JS Tutorial >JS small case: the follower who can't get rid of
This article mainly introduces the following JS cases that cannot be shaken off. Friends in need can refer to it
<br>
根本鼠标的XY值,让元素移动
<body> <img src="image/toux.ico" id="imgbug" alt="移动图片"></body> <script type="text/javascript"> window.onload = function () { var ima = document.getElementById("imgbug"); ima.style.position = "absolute";//让图片绝对定位 //注册鼠标的移动处理函数 document.onmousemove = function () { //改变图片的坐标 //获取鼠标的坐标 var x = event.clientX; var y = event.clientY; ima.style.left = x-ima.offsetWidth+"px"; ima.style.top = y - 76+"px"; } }</script>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>#
The above is the detailed content of JS small case: the follower who can't get rid of. For more information, please follow other related articles on the PHP Chinese website!