移动端触摸事件简介

oBox.ontouchend里面放e.changedTouches事件是为了告诉浏览器,刚才谁在这里了,大概是这么个意思。

1.touches  当前位于屏幕上的所有手指的一个列表
2.targetTouches  位于当前DOM元素上的手指的一个列表
3.changedTouches   涉及当前事件的手指的一个列表

 

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<meta name="viewport" content="width=device-width,target-densitydpi=device-dpi,user-scalable=no">
<style>
div{width:100px;height:100px;background:Red;}
</style>
</head>
<body>
<div id="box"></div>
<script>
var oBox=document.getElementById("box");
oBox.ontouchstart=function(e)
{
    //console.log(e.touches);
};
oBox.ontouchmove=function()
{
    //console.log(e.touches);
};
oBox.ontouchend=function(e)
{
    console.log(e.changedTouches);
};
</script>
</body>
</html>

 

posted @ 2015-05-10 16:01  马斯塔  阅读(220)  评论(0编辑  收藏  举报