您当前的位置: 首页 > 学无止境 > JS经典实例 网站首页JS经典实例
jquery 水平滑动事件touch(触屏)
发布时间:2017-02-12 21:11:16编辑:雪饮阅读()
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="http://apps.bdimg.com/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
var startX, startY, endX, endY;
document.getElementById("divADBox").addEventListener("touchstart", touchStart, false); document.getElementById("divADBox").addEventListener("touchmove", touchMove, false);
document.getElementById("divADBox").addEventListener("touchend", touchEnd, false);
function touchStart(event) {var touch = event.touches[0];startX = touch.pageX;console.log("触摸起点");}
function touchMove(event) {var touch = event.touches[0];endX = touch.pageX;console.log("触摸滑动");} function touchEnd(event) {console.log("触摸释放");}
})</script>
</head>
<body>
<div id="divADBox">aaa</div>
</body>
</html>
关键字词:jquery,touch,滑动