爱梯哒小怪兽
2016-02-19 16:36
list.onmousedown=function(event){
touchstartX=event.clientX;
touchstartY=event.clientY;
console.log("开始"+touchstartY);
}
list.onmousemove=function(event){
touchendX=event.clientX;
touchendY=event.clientY;
console.log("移动"+touchendY);
}
list.onmouseup=function(event){
console.log("结束"+event.clientY);
}
这么写 为什么只显示 开始的 clientY 。onmousemove onmouseup 都不起作用
<div id="div1"></div> 换成图片 还是不行哎 为什么啊?
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
#div1{
background-color:#ccc;
height:400px;
width:300px;
}
</style>
<script>
window.onload=function(){
var list = document.getElementById('div1');
var flag = 0;
list.onmousedown=function(event){
touchstartX=event.clientX;
touchstartY=event.clientY;
console.log("开始"+touchstartY);
flag=1;
}
list.onmousemove=function(event){
touchendX=event.clientX;
touchendY=event.clientY;
if(flag==1){
console.log("移动"+touchendY);
}
}
list.onmouseup=function(event){
console.log("结束"+event.clientY);
flag=0;
}
}
</script>
</head>
<body>
<div id="div1"></div>
</body>
</html>
DOM事件探秘
99544 学习 · 1197 问题
相似问题