ios上单击input输入框无效

场景:在ios手机上,点击input输入框,很难选中

分析后发现单击很难触发onClick事件,只有双击才会触发这个onClick事件

检查 是否加载了 fastclick 库,移动端一般都会安装这个库,区分双击和单击事件,一般情况下都是因为这个导致的,因此解决办法有两种:

1.去掉fastclick库

2.加一段代码: 

if ('addEventListener' in document) {
        document.addEventListener('DOMContentLoaded', function() {
          if (FastClick) {
            FastClick.attach(document.body);
          }
        }, false);
      }
      // 解决ios 微信环境点击input无效 需要双击才生效
      FastClick.prototype.focus = function(targetElement) {

        var length;

// Issue #160: on iOS 7, some input elements (e.g. date datetime month) throw a vague TypeError on setSelectionRange. These elements don't have an integer value for the selectionStart and selectionEnd properties, but unfortunately that can't be used for detection because accessing the properties also throws a TypeError. Just check the type instead. Filed as
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值