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

  • 相关阅读:
    strcpy 详解
    c/c++中static详解
    c/c++中const详解
    12、Java中的接口
    11、java中的模板方法设计模式
    10、java中的抽象类
    9、java中的final关键字
    8、java继承中的this和super的应用
    7、java实现的两种单例模式
    6、java中的构造代码块
  • 原文地址:https://www.cnblogs.com/isdom/p/webclips013.html
Copyright © 2011-2022 走看看