zoukankan      html  css  js  c++  java
  • 获得touch事件,jquery绑定事件监听器,ios设备上打开touch状态以响应focus,active等伪类

    2.

    默认的监听方式

    document.addEventListener('touchstart', function(){ alert('hello'); }, false);

    使用jquery时

    $(document).on('touchstart', function(e){
      var touch = e.originalEvent.touches[0] || e.originalEvent.changedTouches[0];
    });

    2.我们常用:hover,:focus,:active等css伪类做按钮点击的反馈效果,可是这时在移动端开发时会遇到这样一个问题,伪类状态没有反应 pc端ok, 安卓上ok,可遇到iPhone设备就不行了

    1] By default, Safari Mobile does not use the :active state unless there is a touchstart event handler on the relevant element or on the <body>
    在iOS系统的移动设备中,需要在按钮元素或body/html上绑定一个touchstart事件才能激活:active状态。

    document.body.addEventListener('touchstart', function () { //...空函数即可});  

     
    https://developer.apple.com/library/safari/documentation/AppleApplications/Reference/SafariCSSRef/Articles/StandardCSSProperties.html

  • 相关阅读:
    CentOS 7
    CentOS
    CentOS 7
    CentOS 7
    Linux目录结构说明
    CentOS 7
    CentOS 7
    Linux——工具参考篇
    Linux工具进阶
    Selenium——UI自动化测试(2)——How to Download & Install Selenium WebDriver (待续)
  • 原文地址:https://www.cnblogs.com/isdom/p/webclips013.html
Copyright © 2011-2022 走看看