Textarea rows 属性

Textarea 对象参考手册 Textarea 对象

定义和用法

rows 属性设置或返回 textarea 的高度。

语法

设置 rows 属性:

textareaObject.rows=number

返回 rows 属性:

textareaObject.rows

提示: rows 属性没有默认值。

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


浏览器支持

Internet ExplorerFirefoxOperaGoogle ChromeSafari

所有主流浏览器都支持 rows 属性


实例

实例

更改文本域的可见行数:

<html>
<head>
<script>
function displayResult()
{
document.getElementById("myTextarea").rows=10;
}
</script>
</head>
<body>

<textarea id="myTextarea" cols="20">
At W3Schools you will find all the Web-building tutorials you need, from basic HTML to advanced XML, SQL, ASP, and PHP.
</textarea>
<br>

<button type="button" onclick="displayResult()">Change number of visible rows</button>

</body>
</html>



Textarea 对象参考手册 Textarea 对象