Textarea autofocus attribute
Definition and Usage
autofocus
Attribute sets or returns whether the text area should automatically gain focus when the page is loaded.
This attribute reflects the HTML autofocus attribute.
See also:
HTML Reference Manual:HTML <input> autofocus attribute
Example
Check if the text area automatically gains focus when the page is loaded:
var x = document.getElementById("myTextarea").autofocus;
Syntax
Return the autofocus attribute:
textareaObject.autofocus
Set the autofocus attribute:
textareaObject.autofocus = true|false
attribute value
value | description |
---|---|
true|false |
Specifies whether the text area should gain focus when the page loads
|
Technical Details
Return Value: | Boolean value, returned if the text area automatically gains focus when the page loads true ; otherwise return false |
---|
Browser Support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | 10.0 | Support | Support | Support |