<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<style>
#div1 {width: 100px; height: 100px; background: red; position: absolute;}
</style>
<script>
window.onload = function() {
var oDiv=document.getElementById("div1");
oDiv.onmousedown=function(){//onmousedown之后为什么内部的onmousemove可以一直触发?后面的onmousemove函数作用域是在onmousedown函数内部的,我认为应该每次鼠标按下onmousedown的时候才能使onmousemove的函数起作用啊?
console.log("onmousedown成功");
oDiv.onmousemove=function(){
console.log("onmousemove成功");
}
}
}
</script>
</head>
<body>
<div id="div1"></div>
</body>
</html>
子衿沉夜
相关分类