<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
*{
margin: 0;
padding: 0;
}
div{
position: absolute;
left:0;
top:0;
width:100px;
height:100px;
border-radius: 50%;
background: yellow;
}
</style>
</head>
<body>
<div></div>
<script>
var oDiv=document.getElementsByTagName('div')[0];
var lastX = oDiv.offsetLeft;
var lastY = oDiv.offsetTop;
oDiv.onmousedown = function(e){
//点击就清除计时器,防止定时器未结束造成bug
clearInterval(this.timer);
var event = e || window.ev
JavaScript模拟重力场
最新推荐文章于 2025-07-07 11:32:04 发布