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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s