Easy Tutorial
❮ Prop Search Type Prop Style Outline ❯

autofocus Attribute for Textarea

Textarea Object


Example

Check if the textarea automatically gains focus:

var x = document.getElementById("myTextarea").autofocus;

Definition and Usage

The autofocus attribute is used to set or return whether the textarea should automatically gain focus when the page loads.


Browser Support

Attribute Chrome IE Firefox Safari Opera
autofocus Yes 10.0 Yes Yes Yes

Syntax

Return the autofocus attribute:

textareaObject.autofocus

Set the autofocus attribute:

textareaObject.autofocus = true|false

Attribute Values

Value Description
true false Specifies whether the textarea should automatically gain focus when the page loads. true - The textarea element gains focus automatically. false - Default. The textarea element does not gain focus.

Technical Details

| Return Value: | A Boolean value, returns true if the textarea is set to automatically gain focus on page load, otherwise returns false. |


Textarea Object

❮ Prop Search Type Prop Style Outline ❯