Easy Tutorial
❮ Prop Doc Body Prop Text Autofocus ❯

readOnly Attribute for Textarea

Textarea Object


Example

Set the textarea to read-only:

document.getElementById("myTextarea").readOnly = true;

Definition and Usage

The readOnly property sets or returns whether the textarea is read-only.

In a read-only text area, the content cannot be changed, but users can still tab through it, highlight, and copy its content.


Browser Support

Property Chrome Edge Firefox Safari Opera
readOnly Yes Yes Yes Yes Yes

Syntax

Set the readOnly property:

textareaObject.readOnly = true|false

Return the readOnly property:

textareaObject.readOnly

Property Values

Value Description
true The textarea is read-only.
false Default. The textarea can be modified.

Technical Details

| Return Value: | Boolean, returns true if the textarea element is read-only, otherwise returns false. |


More Examples

Example

Check if the textarea is read-only:

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

Textarea Object

❮ Prop Doc Body Prop Text Autofocus ❯