【问题标题】:focus() doesn't work in IE 11focus() 在 IE 11 中不起作用
【发布时间】:2016-06-22 07:18:54
【问题描述】:

我有以下 HTML

<div id="blocked-layer-parent">
    <textarea id="paint-textarea" placeholder="Enter text" autofocus><%-sometext%></textarea>
    <div id="blocked-layer"></div>
</div>

IE 11 自动对焦 不起作用。我尝试像这样使用 focus 函数:

$("#paint-textarea").focus();

或者这个:

var textAreaElement = document.getElementById("paint-textarea");
setTimeout(function() {
    textAreaElement.focus();
}, 2100);

textareaIE 11 中没有获得焦点。我查看了不同的决定(例如jQuery focus() sometimes not working in IE8focus doesn't work in IE),但没有一个不起作用。

感谢您的帮助。

P.S. textareaplaceholder 正在转换为文本 (textelement)在 IE 中。我觉得很奇怪。在应用程序的其他模块中,我有 inputplaceholder 用于搜索。这个 placeholder 像占位符一样工作(在输入字符后消失)。在一些显示 placeholder 的对话框在文本中转换并且搜索停止工作后。也许问题与此有关?

【问题讨论】:

标签: javascript internet-explorer focus internet-explorer-11


【解决方案1】:

我在jsFiddle 上尝试了纯 html 和 js,它可以工作。也许 css 会导致问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-31
    • 2018-05-15
    • 2015-05-06
    • 2016-10-13
    • 2018-03-29
    • 2017-08-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多