<div id="div3"></div>
```javascript
在这里插入代码片
var div3 = document.getElementById("div3")
// onmousedown 鼠标键按下事件
div3.onmousedown = function(){
// onmousemove 鼠标键移动事件
document.onmouseMove = function(event){
event = event || window.event;
// 获取鼠标的当前坐标
var left = event.clientX;
var top = event.clientY;
// 鼠标移动后获取当前坐标
div3.style.left = left + "px"
div3.style.top = top + "px"
}
// 松开鼠标键
div3.onmouseup = function(){
document.onmousemove = null;
}
}
```css
#div3{
height: 100px;
width: 100px;
background-color: red;
}