HTMLTextAreaElement: defaultValue プロパティ

Baseline Widely available

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

defaultValueHTMLTextAreaElement インターフェイスのプロパティで、このテキストエリアの既定のテキストコンテンツを示します。この値を取得または設定することは、 <textarea>textContent を取得または設定するのと同じです。

文字列です。

下記の例では、defaultValue は元々 HTML で記述されていた値を返します。既定値が HTML または defaultValue プロパティのいずれかで設定されている場合、ユーザーが入力すると value が更新されますが、 defaultValue を上書きすることはありません。

js
const textareaElement = document.getElementById("comment");
console.log(textArea.defaultValue);
textArea.defaultValue = "This is the default text now!";

仕様書

Specification
HTML
# dom-textarea-defaultvalue

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
defaultValue

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

関連情報