12345678910111213141516171819202122232425262728293031323334353637383940 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Document</title>
- <style>
- #box {
- width: 200px;
- height: 200px;
- background: #0f0;
- }
- </style>
- </head>
- <body>
- <!--
- touchstart:手指触摸到一个 DOM 元素时触发。
- touchmove:手指在一个 DOM 元素上滑动时触发。
- touchend:手指从一个 DOM 元素上移开时触发。
- 每个触摸事件都包括了三个触摸列表,每个列表里包含了对应的一系列触摸点(用来实现多点触控)
- touches:当前位于屏幕上的所有手指的列表。
- targetTouches:位于当前DOM元素上手指的列表。
- changedTouches:涉及当前事件手指的列表
- click会有200-300ms延迟
- -->
- <div id="box"></div>
- <script>
- var box = document.getElementById("box");
- box.ontouchstart = function() {
- console.log("开始");
- }
- box.ontouchmove = function(event) {
- console.log("移动",event);
- }
- box.ontouchend = function() {
- console.log("离开");
- }
- </script>
- </body>
- </html>
|