| 123456789101112131415161718192021222324252627282930313233343536373839 |
- <!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: 100px;
- height: 100px;
- background-color: pink;
- }
- </style>
- </head>
- <body>
- <div class="box"></div>
- <script>
- var oBox = document.querySelector(".box");
- // 鼠标点击事件
- // 鼠标点击会有一个300毫秒的延迟
- oBox.onclick = function(){
- console.log("点击事件");
- }
- // 移动端点击事件
- // 移动端点击事件不会有延迟
- oBox.ontouchstart = function(){
- console.log("移动端点击start事件");
- }
- // 移动端点击事件会有一个
- oBox.ontouchend = function(){
- console.log("移动端点击end事件");
- }
- // touchmove 移动端滑动事件
- oBox.ontouchmove = function(){
- console.log("移动端滑动事件");
- }
- </script>
- </body>
- </html>
|