【问题标题】:jQuery blur not working on iOSjQuery模糊不适用于iOS
【发布时间】:2016-11-16 18:03:51
【问题描述】:

我有一个简单的文本区域,如果我使用 iPad 或 iPhone 专注于它,焦点将停留在该文本区域上,直到我单击另一个字段或链接。我想删除点击其他元素的焦点,并在具有 contenteditable 属性的 div 上执行相同操作;所以,当我在某处读到时,我试过这个:

$('body').click(function(e) {
        if (!$('#text-to-change').is(e.target)) {
            $('#text-to-change').blur();
        } else {
            $('#text-to-change').focus();
        }
    });

它不起作用...焦点停留在那个文本区域上。

【问题讨论】:

    标签: javascript jquery ios focus blur


    【解决方案1】:

    iOS 不支持移动端的焦点和模糊,对于模糊我找到了一个使用 CSS 的解决方案,如果有其他解决方案,请写下,我很感兴趣

    CSS:

    // search input box blur support
    
    //iPhone 6 in portrait & landscape
    @media only screen
      and (min-device-width : 375px)
      and (max-device-width : 667px) {
        body { cursor: pointer; }
    }
    
    //iPhone 6 Plus in portrait & landscape
    @media only screen
      and (min-device-width : 414px)
      and (max-device-width : 736px) {
        body { cursor: pointer; }
    }
    
    // iPhone 5 & 5S in portrait & landscape
    @media only screen
      and (min-device-width : 320px)
      and (max-device-width : 568px) {
    
        body { cursor: pointer; }
    }
    

    【讨论】:

      猜你喜欢
      • 2012-09-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-06-14
      • 1970-01-01
      相关资源
      最近更新 更多