關于clientY
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 都不起作用
2016-02-24
<div id="div1"></div> 換成圖片 還是不行哎 為什么?。?/p>
2016-02-20
<!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>