使用jquery的on事件绑定或$(document).on(‘click‘)绑定单击事件,在苹果手机浏览器上点击无效果

    技术2022-07-10  98

    日常怕坑之路,哈哈,产品反馈的问题,小赵啊在苹果的部分机型上点击事件不起作用了,有时候真心觉得程序员经验就是靠bug给堆起来的。 安卓机子,模拟测试正常,苹果上确实有问题哈哈

    经查阅资料 看到有一种解决方法 在需要点击的对象上面 添加 css样式 cursor:pointer; 至于为什么,本猜测可能看起来是人用手进行点击的哈哈

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <script src="https://cdn.bootcss.com/jquery/1.11.3/jquery.min.js"></script> <style> .demo{cursor:pointer;} </style> </head> <body> <div class="demo"> </div> <script> $(document.body).on('click','demo',function(){ alert('hello world') }) </script> </body> </html>
    Processed: 0.010, SQL: 9