Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Textarea autofocus property

Textarea autofocus property

Textarea Object Reference The Textarea object


Example

Check whether the textarea automatically gets focus:

var

x

=

document

.

getElementById

(

"

myTextarea

"

)

.

autofocus

;

Try it »

Definition and Usage

The autofocus property is used to set or return whether the textarea text box should automatically get focus when the page loads.


Browser support

property
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 text box automatically gets focus when the page loads.

  • true - the textarea element automatically gets focus.
  • false - default. the textarea element does not get focus.
  • |

    Technical Details

    Return value: A boolean, returns true if automatic focus is set when the page loads, otherwise returns false.

    Textarea Object Reference The Textarea object