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