Latest web development tutorials

HTML DOM Textarea rows property

Textarea Object Reference Textarea object

Definition and Usage

rows property sets or returns textarea height.

grammar

Setting rows attributes:

textareaObject.rows=number

Returns rows attributes:

textareaObject.rows

Tip: rows property has no default value.

描述
number 指定在文本区域中可见的行数


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support rows property


Examples

Examples

Change the text field visible lines:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
<script>
function displayResult()
{
    document.getElementById("myTextarea").rows=10;
}
</script>
</head>
<body>

<textarea id="myTextarea" cols="20">
在本教程,你可以学多很多编程的基础知识,包括 HTML, XML, SQL, ASP, 和 PHP 等各种前端内容。
</textarea>
<br>

<button type="button" onclick="displayResult()">修改可见行数</button>

</body>
</html>



Textarea Object Reference Textarea object