您的位置:首页 > 其它

手机页面touch触摸事件

2016-12-19 10:54 483 查看
请看示例:

<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title></title>
<style>
.main-div{
font-size:4rem;
width:100%;
}
</style>
<script type="text/javascript" src="jquery-2.1.1.js"></script>
</head>
<body>
<div class="main-div">
hello wor1ld!
</div>
</body>
</html>

<script type="text/javascript">
$(".main-div").bind("touchstart", function (e) {   //触摸开始的时候触发
//e.preventDefault();  //阻止出现滚动条
$(this).css("background-color", "#e5e5e5");
}).bind("touchend", function (e) {                  //手指在屏幕上滑动的时候触发
$(this).css("background-color", "white");
}).bind("touchmove", function (e) {                 //触摸结束的时候触发
$(this).css("background-color", "white");
});
</script>


延伸阅读文章: http://www.w3school.com.cn/jquerymobile/jquerymobile_events_touch.asp
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: