无法模糊ios中的输入 [英] can't blur input in ios

查看:89
本文介绍了无法模糊ios中的输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Xcode,Cordova和HTML文件构建iPad应用.

I'm building an iPad app using Xcode, Cordova and HTML files.

在iPad上测试HTML时,我无法通过在输入字段外面单击来使输入字段模糊.

In testing the HTML on an iPad, I'm not able to blur my input fields by clicking outside them.

我需要对背景进行编码以使输入模糊吗?

Do I need to code the background to blur the input?

我想要模糊效果,以便隐藏键盘.

I want the blur so I can hide the keyboard.

除非有一种更好的解决方案可以隐藏它,而无需blur().

Unless there's a better solution to hiding it that does not need a blur().

推荐答案

我发现了两个代码段,当单击输入之外的任何地方或按Return键时,这些代码段组合在一起可触发输入模糊.

I found two code snippets that combine to trigger blur on inputs when clicking anywhere outside the input, or when pressing the Return key.

function isTextInput(node) {
    return ['INPUT'].indexOf(node.nodeName) !== -1;
}
document.addEventListener('touchstart', function(e) {
    if (!isTextInput(e.target) && isTextInput(document.activeElement)) {
    document.activeElement.blur();
    }
}, false);
$('input').keyup(function(event) {
    if (event.which === 13) {
      $(this).blur();
    }
});

这篇关于无法模糊ios中的输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆