定时器
setTimeout 单次定时 第一个参数是匿名函数 第二参数是多少毫秒后执行 第三个函数是返回值(返回的是地址)clearTimeout() 清除定时器setInterval 多次定时 第一个参数是匿名函数 第二参数是多少毫秒后执行 第三个函数是返回值(返回的是地址)clearInterval() 清除定时器
拖拽
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>拖拽效果</title>
<style>
#box{
width: 200px;
height: 200px;
background-color: black;
position: relative;
left:100px;
}
</style>
</head>
<body>
<div id='box' οnmοusedοwn="mv(this)" >
</div>
<script>
function mv(_this){
// console.log('我是鼠标按下事件')
_this.οnmοusemοve=function(event){
console.log('我是移动事件')
// console.log(event)
// console.log(_this)
_this.style.left = event.clientX-100+"px"
_this.style.top = event.clientY-100+"px"
}
_this.οnmοuseup=function(){
_this.οnmοusemοve=null
}
}
</script>
</body>
</html>
转载请注明原文地址:https://blackberry.8miu.com/read-8546.html