- What is autofocus in JavaScript?
- How to set autofocus in JavaScript?
- How do you autofocus input?
- Why is autofocus bad for accessibility?
What is autofocus in JavaScript?
Definition and Usage. The autofocus property sets or returns whether a text field should automatically get focus when the page loads, or not. This property reflects the HTML autofocus attribute.
How to set autofocus in JavaScript?
As simple as document. getElementById('your_text_box_id'). focus(); .
How do you autofocus input?
The autofocus attribute is a boolean attribute. When present, it specifies that an <input> element should automatically get focus when the page loads.
Why is autofocus bad for accessibility?
Accessibility considerations
Automatically focusing a form control can confuse visually-impaired people using screen-reading technology and people with cognitive impairments. When autofocus is assigned, screen-readers "teleport" their user to the form control without warning them beforehand.