当前位置:网站首页>Js- get the mouse coordinates and follow them
Js- get the mouse coordinates and follow them
2022-06-25 14:54:00 【-multiflora-】
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style type="text/css">
#box1{
width: 100px;
height: 100px;
background-color: #bbffaa;
/* Turn on box1 The absolute positioning of */
position: absolute;
}
</style>
<script type="text/javascript">
window.onload = function (){
/* * bring div You can follow the mouse * */
var box1 = document.getElementById("box1");
document.onmousemove = function (event){
// Solve compatibility problems
event = event || window.event
// Get mouse coordinates
var left = event.pageX;
var top = event.pageY;
// Set up div The offset
box1.style.left = left + "px";
box1.style.top = top + "px";
}
}
</script>
</head>
<body>
<div id="box1"></div>
</body>
</html>

边栏推荐
- Clipboard tutorial
- What is the difference between escape, encodeuri and encodeuricomponent?
- Biscuit distribution
- Jaspersoft studio adding MySQL database configuration
- 关于win10 版本kicad 卡死的问题, 版本6.x
- Jaspersoft studio installation
- [HBZ sharing] use of locksupport
- Character encoding minutes
- Master XSS completely from 0 to 1
- From 408 to independent proposition, 211 to postgraduate entrance examination of Guizhou University
猜你喜欢

C language escape character and its meaning

如何裁剪动图大小?试试这个在线照片裁剪工具

【Try to Hack】vulhub靶场搭建

QQ love talk candy love talk content acquisition and storage

Yolov3 spp Darknet version to caffemodel and then to OM model

有哪个瞬间让你觉得这个世界出bug了?

定位position(5种方式)

TSDB在民机行业中的应用

Heavyweight! The domestic IDE is released and developed by Alibaba. It is completely open source! (high performance + high customization)

In 2022, the score line of Guangdong college entrance examination was released, and several families were happy and several worried
随机推荐
[Ocean University of China] Data Sharing for retest of initial Examination
Where is it safe to open an account for buying funds? Ask for guidance
Mutationobserver listens for DOM changes
Position (5 ways)
Add the resources directory under test in idea
Application of TSDB in civil aircraft industry
Character encoding minutes
Jaspersoft studio installation
Custom instruction, mixing, routing, lifecycle
Remove interval (greedy)
[untitled]
如何裁剪动图大小?试试这个在线照片裁剪工具
[Ocean University of China] information sharing for the first and second examinations of postgraduate entrance examination
弹性布局(display:flex;)属性详解
What is the difference between escape, encodeuri and encodeuricomponent?
[HBZ sharing] use of locksupport
C language LNK2019 unresolved external symbols_ Main error
Clinical Chemistry | 张建中/徐健开发幽门螺杆菌单细胞精准诊疗技术
Output 0 ~ n digits and output multiple times
Async await to achieve sleep waiting effect