【问题标题】:Autocomplete removes focus on mobile view自动完成消除了对移动视图的关注
【发布时间】:2018-10-08 09:34:10
【问题描述】:

目前,当我在搜索栏中输入三个字母时,自动完成功能将开始工作,并且键盘开始在移动设备上隐藏。

我使用的代码是

jQuery("input#search").focus();

jQuery("input#search").blur(function() {
    setTimeout(function() { jQuery("input#search").focus(); }, 0);
});

当我将它用于 android 设备时,自动完成功能会移除键盘,但会立即将其带回来,但 ios 会开始一次又一次地隐藏它。

是否有另一种可能只说“阻止所有会移除焦点的东西”或“当失去焦点时立即将它带回来”?

【问题讨论】:

  • 试试 autocomplete="off" autocorrect="off"spellcheck="false" 用于输入元素。
  • 不起作用:(
  • make element readonly + disable on blur event like。 $("input#search").prop("readonly", true); $('input#search').prop('disabled', true); 并在超时后再次删除。
  • 你有完整的代码给我吗.. 我完全不明白你的意思

标签: javascript jquery magento search


【解决方案1】:

试试下面的代码 sn-p

$("input#search").focus();

    $("input#search").blur(function(e) {
        e.preventDefault();
        e.stopPropagation();
        $( this ).prop( "disabled", true );
        $( this ).prop( "readonly", true );
        setTimeout(function() { $("input#search").focus(); }, 100);
    });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<input type="text" id="search" />

【讨论】:

    猜你喜欢
    • 2016-03-09
    • 1970-01-01
    • 2016-12-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-01
    • 1970-01-01
    相关资源
    最近更新 更多