HTMLInputElement: 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
は HTMLInputElement
インターフェイスのプロパティで、<input>
要素の元の(または既定の)値を示します。これは、この要素の value
属性を反映します。
値
<input>
要素の既定値、または元の値を表す文字列です。
例
以下の HTML があったとします。
html
<label for="planet">Which planet were you born on?</label>
<input id="planet" type="text" value="Azarath" />
次のものは、ユーザーがテキスト入力に何を入力しても同じ結果を提供します。
js
const inputElement = document.querySelector("#planet");
console.log(`元の値: ${inputElement.defaultValue}`); // "元の値: Azarath"
仕様書
Specification |
---|
HTML # dom-input-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.