如果使用javascript创建,则无法在ie 11中键入输入类型文本!:(

input type text cant be typed into in ie 11 if created using javascript! :(

本文关键字:输入 类型 文本 ie 创建 javascript 如果      更新时间:2023-09-26

这是我创建的最简单的示例,在ie 11中不起作用:(它真的不会让我输入文本!

<!DOCTYPE html>
<html>
<body>
<script type='text/javascript'>
var text = document.createElement('input');
text.type = 'text';
document.documentElement.appendChild(text);
</script>
</body>
</html>

我该如何绕过这个荒谬的bug?我正在构建一个复杂的网站,它使用javascript生成大部分html。

document.documentElement将是您的html页面,您正试图将一个元素附加为documentElement的innerHTML的同级元素。

使用body:代替documentElement

var text = document.createElement('input');
text.type = 'text';
document.body.appendChild(text);

去过那里。。。我不得不把重点放在输入上。

$("input").click(function(){ $(this).closest('input').focus()})