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 2015年7月.
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> |
ブラウザーの互換性
Loading…