sfdsfdsfd sfdsfdsfd
sfdsfdsfd sfdsfdsfd

Reputation: 13

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

This is the simplest example i created and this does not work in ie 11 :( It literally will not let me type into the text input!

<!DOCTYPE html>
<html>
<body>

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

How can I get around this ridiculous bug? I am building a sophisticated website that generates most of the html using javascript.

Upvotes: 1

Views: 255

Answers (2)

Jai
Jai

Reputation: 74738

document.documentElement will be your html page and you are trying to append an element as a sibling of the documentElement's innerHTML.

instead of documentElement use body:

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

Upvotes: 1

Alvaro Silvino
Alvaro Silvino

Reputation: 9733

Been there... I had to force the focus on the input.

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

Upvotes: 0

Related Questions