HTMLTextAreaElement: rows プロパティ - Web API | MDN

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2015年7月.

rowsHTMLTextAreaElement インターフェイスのプロパティで、このテキストコントロールのテキストが見える行数を表す正の整数です。これは <textarea> 要素の rows 属性を反映します。

正の整数です。既定値は 2 です。

js

const textareaElement = document.getElementById("comment");
const textLines = textArea.rows;
textArea.rows = textLines + 2;

仕様書

Specification
HTML
# dom-textarea-rows

ブラウザーの互換性

関連情報

Help improve MDN

Learn how to contribute

This page was last modified on by MDN contributors.