【发布时间】: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);
但 textarea 在 IE 11 中没有获得焦点。我查看了不同的决定(例如jQuery focus() sometimes not working in IE8 和focus doesn't work in IE),但没有一个不起作用。
感谢您的帮助。
P.S. textarea 的 placeholder 正在转换为文本 (textelement)在 IE 中。我觉得很奇怪。在应用程序的其他模块中,我有 input 和 placeholder 用于搜索。这个 placeholder 像占位符一样工作(在输入字符后消失)。在一些显示 placeholder 的对话框在文本中转换并且搜索停止工作后。也许问题与此有关?
【问题讨论】:
-
@wybeen ty,但没有帮助
标签: javascript internet-explorer focus internet-explorer-11