深入理解移动端touch事件
2016-05-23 17:57
363 查看
相关链接:http://blog.csdn.net/cometwo/article/details/50534611
<!DOCTYPE html> <html lang="en"> <head> <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" /> <meta charset="UTF-8" /> <title>Document</title> <style type="text/css"> div { width: 200px; height: 200px; background: red; margin: 0 auto; } </style> <script type="text/javascript"> window.onload = function() { document.getElementById('touch').ontouchmove = function(e) { console.log(e.type); }; document.getElementById('touch').ontouchend = function(e) { console.log(e.type); }; document.getElementById('touch').onclick = function(e) { console.log(e.type); }; document.getElementById('touch').ontouchstart = function(e) { console.log(e.type + ';' + e.target.nodeName ); }; } </script> </head> <body> <div id="touch"></div> </body> </html>
JQuery 强迫症患者
<!DOCTYPE html> <html lang="en"> <head> <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" /> <meta charset="UTF-8" /> <script type="text/javascript" src="jquery-2.1.4.min.js" ></script> <title>Document</title> <style type="text/css"> div { width: 200px; height: 200px; background: red; margin: 0 auto; } </style> <script type="text/javascript"> $( function() { $("#touch").get(0).ontouchmove = function(e) { console.log(e.type); }; $("#touch").get(0).ontouchend = function(e) { console.log(e.type); }; $("#touch").get(0).onclick = function(e) { console.log(e.type); }; $("#touch").get(0).ontouchstart = function(e) { console.log(e.type + ';' + e.target.nodeName ); }; }) </script> </head> <body> <div id="touch"></div> </body> </html>
相关文章推荐
- UIWebView加载html 图片大小自适应的方法汇总
- Android App的设计架构:MVC,MVP,MVVM经验谈
- iOS 9 Auto Layout界面自动布局系列6-自适应布局
- 如何检测手机系统,如何检测页面是微信还是QQ打开
- Swift官文阅读记录一(基础)
- Volley 源码解析
- iOS开发——毛玻璃透明
- Android SDK 国内镜像
- Android组件Activity初探
- 支持多版本接口api的开源框架NHVersion
- Android Dev Intro - Some Concepts on Android Graphics Architecture
- android组件之BroadcastReceiver广播
- Appium学习第一个测试脚本
- Appium学习第一个测试脚本
- Android自定义View初步
- Appium的一点一滴
- android studio之gradle的更新
- Appium windows的安装
- Appium Python API
- 趟过Appium的坑