1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- <!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-color: red;
- }
- .box2{
- width: 100px;
- height: 100px;
- background-color: blue;
- position: absolute;
- top: 50px;
- left: 50px;
- }
- </style>
- </head>
- <body>
- <div class="box"></div>
- <div class="box2"></div>
- <script>
- var oBox = document.querySelector(".box");
- var oBox2 = document.querySelector(".box2");
- // 点透事件 需要避免在移动端使用click事件
- oBox2.ontouchstart = function(){
- console.log("触摸事件");
- this.style.display= "none";
- }
- oBox.onclick =function(){
- console.log("点击事件");
- }
- // oBox.onclick = function(){
- // console.log("hello")
- // }
- // touchstart 触摸开始
- // oBox.ontouchstart = function(){
- // console.log("触摸开始");
- // }
- // // touchend 触摸结束
- // oBox.ontouchend = function(){
- // console.log("触摸结束");
- // }
- // // touchmove 触摸移动
- // oBox.ontouchmove = function(){
- // console.log("触摸移动");
- // }
- </script>
- </body>
- </html>
|