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.
defaultValue
は HTMLTextAreaElement
インターフェイスのプロパティで、このテキストエリアの既定のテキストコンテンツを示します。この値を取得または設定することは、 <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 GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
defaultValue |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.