• 获得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

  • 相关阅读:
    Bootstrap3 代码-代码块
    DB2 911错误的解释
    Bootstrap3 代码-用户输入
    Bootstrap3 代码-内联代码
    Bootstrap3 排版-列表
    Bootstrap3 排版-引用
    Bootstrap3 排版-地址
    Bootstrap3 排版-缩略语
    Bootstrap3 排版-改变大小写
    Bootstrap3 排版-对齐
  • 原文地址:https://www.cnblogs.com/isdom/p/webclips013.html
Copyright © 2020-2023  润新知