Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML5 auto focus not working in firefox [duplicate]

I am working with and angular JS and HTML5 application. I have a login form with username and password field. when the login page loads i want the focus to be on the username by default.i have used HTML5 autofocus="autofocus" to implement this without writing any script.

 <input name="USER" id="USER" type="email" class="input-control" data-ng-model="login.userName" required autofocus="autofocus">

This works fine in Google Chrome, Internet Explorer and Safari. however the autofocus is not working in Mozilla Firefox.i have red about some issues with autofocus in firefox for old versions. i am using version 48.0

Any solutions? Thanks in advance

like image 474
Shareer Avatar asked Nov 29 '16 10:11

Shareer


1 Answers

$('#element').focus() should work

This question has already been asked and answered here: Autofocus Attribute of HTML5 does not work only in FireFox when <Form><input> are loaded via Ajax. WHY? and here: Autofocus doesn't work on Firefox and doesn't work when coming from another page

like image 172
ArthurG Avatar answered Nov 01 '22 07:11

ArthurG