天天看點

Textarea rows 屬性

Textarea 對象

執行個體

修改文本框 textarea 的行數(高度):

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

定義和用法

rows 屬性設定或傳回 textarea 的 rows 屬性值。

rows 屬性指定文本框的高度(行數)。

提示: 你可以使用

style.heigth 屬性來設定 textarea 元素的高度。

提示: 你可以使用 cols

和 style.width 屬性來設定 textarea 元素的寬度和高度。

浏覽器支援

Property
rows Yes

文法

設定 rows 屬性:

textareaObject.rows=number      

傳回 rows 屬性:

textareaObject.rows      
提示:

rows 屬性沒有預設值。

屬性值

描述
number 指定在文本區域中可見的行數

技術細節

傳回值: 一個數字,表示文本框的高度。

更多執行個體

擷取 textarea 元素的高度(rows 屬性的值):

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

使用 style.height 修改 textarea 元素的高度:

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

使用 textarea 元素的 cols 和 rows 屬性修改高度和寬度:

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

Textarea 對象

上一篇: 再談異步
下一篇: 再談ALM