Textarea rowsProperty

Textarea 对象参考手册Textarea Object

Example

Modify the number of rows (height) of the textarea:

document.getElementById("myTextarea").rows = "10";

Try it Yourself »

Definition and Usage

The rows property sets or returns the value of the rows attribute of a textarea.

The rows attribute specifies the height (number of rows) of the text area.

Tip:You can use the style.heigthproperty to set the height of a textarea element.

Tip:You can use thecolsandstyle.widthproperty to set the width and height of a textarea element.



Browser Support

Property
rows Yes Yes Yes Yes Yes

Syntax

To set the rows property:

textareaObject.rows=number

To return the rows property:

textareaObject.rows

Tip:The rows property has no default value.



Property Values

Value Description
number Specifies the number of visible rows in the text area.


Technical Details

Return Value: A number representing the height of the text area.

More Examples

Example

Get the height of a textarea element (the value of the rows attribute):

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

Try it Yourself »

Example

Use style.height to change the height of a textarea element:

document.getElementById("myTextarea").style.height = "250px";

Try it Yourself »

Example

Use the cols and rows attributes of a textarea element to modify the height and width:

document.getElementById("myTextarea").rows = "10"; document.getElementById("myTextarea").cols = "100";

Try it Yourself »


Textarea 对象参考手册Textarea Object

Other Extensions