码迷,mamicode.com
首页 > 移动开发 > 详细

javascript 在移动端鼠标事件点透问题

时间:2019-10-02 14:44:28      阅读:136      评论:0      收藏:0      [点我收藏+]

标签:meta   html   dde   device   idt   head   记录   osi   listener   

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        #box{
            position: absolute;
            left:0;
            top:0;
            width:200px;
            height:200px;
            background:red;
            opacity:.2;
        }
    </style>
</head>
<body>
    <a href="https://www.baidu.com">百度</a>
    <div id="box"></div>
    <script>
        {
        /*
          touchstart 手指在元素上摁下
          touchmove 手指在元素摁下之后,在屏幕中移动
          touchend  手指在元素摁下之后,然后抬起
        
        */
           let box=document.querySelector("#box");
            box.addEventListener("touchend",()=>{
                
                box.style.display="none";
                e.preventDefault();
            });
        /* 
            移动端中,到底支不支持鼠标事件?

            移动端鼠标事件问题:300ms左右的延迟
            当我们在移动端手指触碰元素之后,会立即执行我们的touch事件,然后会记录当前触发事件的坐标
            300毫秒之后,在该坐标查找元素,如果该元素有对应的鼠标事件,就执行   

            事件点透解决方案:
            1.在移动端 不要使用鼠标事件 (包括a的href)
            2.阻止默认事件
        */
      
      
        }
    </script>
</body>
</html>

 

javascript 在移动端鼠标事件点透问题

标签:meta   html   dde   device   idt   head   记录   osi   listener   

原文地址:https://www.cnblogs.com/supermanGuo/p/11617256.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!