jquery_mobile => 监控手势触摸

本文介绍了一个使用TouchIt插件实现触摸事件响应的HTML页面示例。该示例通过jQuery库加载了TouchIt插件,并为一个蓝色方块元素绑定了触摸开始、移动、结束、双击及捏合缩放等事件处理器。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<!DOCTYPE html>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>TouchIt Demo</title>
		
		<meta name="viewport" content="initial-scale=1.0,maximum-scale=1.0,height=device-height,width=device-width,user-scalable = no">

		<script src="./jquery-2.0.3.js" type="text/javascript"></script>
		<script src="http://glyde.eu/touchit-1.0.0.js" type="text/javascript"></script>
		<script type="text/javascript">

			
			$(document).ready(function () {
				
				$( "#touch" ).touchit({
					onTouchStart: function (x, y) {
						$("#touched").text('Touch Start ' + x + ':' + y);
					},
					onTouchMove: function (x, y) {
						$("#touched").text("Touch Move " + x + ':' + y);
					},
					onTouchEnd: function (x, y) {
						$("#touched").text("Touch End " + x + ':' + y);
					},					
					onDoubleTap: function (x, y) {
						$("#touched").text("Double Tap " + x + ':' + y);
					},
					onPinch: function (scale) {
						$("#touched").text("Pinch " + scale);
					}
				});

            });

		</script>
	   
	</head>
	<body style="margin:0px;">
		<span id="touched" style="width:10px;height:10px; ">Touch and pinch the blue square...</span>
		<div id="touch" style="width:250px;height:250px;background: blue; "></div>
	</body>
</html>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值