Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make input on autofocus for IE browsers?

Tags:

html

css

input

I want to be able to make my input on autofocus but when I put it like this:

<input type="text" autofocus="focus"> 

it doesnt work?

Why is this?

like image 914
Lizzie Moore Avatar asked Dec 03 '22 00:12

Lizzie Moore


1 Answers

autofocus attribute isn't supported by IE, so you need to use Javascript. If you use jquery, you can emulate it:

<input type="text" autofocus="focus"> 
<script>
    $(function() {$('[autofocus]').focus()});
</script>

When IE catches up and adds full autofocus support, you can remove the script from your webpage.

like image 74
socha23 Avatar answered Jan 19 '23 01:01

socha23