Focus doesn’t work on IE

I’m documenting this cause i took me a long while to solve it. For some reason, i don’t know why, my input field couldn’t get focused. Here is the code similar of the one i was using:

myInput = document.getElementById("selected");
myInput.focus();

My solution was to add the select() method after i call the focus(), like this:

myInput.focus().select();

I hope it can help people with the same problem.

Advertisements