Input Month defaultValue attribute
Definition and Usage
defaultValue
Sets or returns the default value of the month field.
Note:The default value is HTML value attribute specified in.
The difference between defaultValue and value properties is that defaultValue contains the default value, while value contains the current value after some changes. If there is no change, defaultValue and value are the same (see "More Examples").
The defaultValue property is very useful if you want to check whether the month/year of the month field has changed.
Instance
Example 1
Change the default value of the month field:
document.getElementById("myMonth").defaultValue = "2023-06";
Example 2
Get the default value of the month field:
var x = document.getElementById("myMonth").defaultValue;
Example 3
An example showing the difference between the defaultValue and value properties:
var x = document.getElementById("myMonth"); var defaultVal = x.defaultValue; var currentVal = x.value;
Syntax
Return the defaultValue property:
monthObject.defaultValue
Set the defaultValue property:
monthObject.defaultValue = value
Attributwert
Wert | Beschreibung |
---|---|
value | Gibt den Standardwert des Monatsfelds an. |
Technische Details
Rückgabewert: | Zeichenkettenwert, der den Standardwert des Monatsfelds darstellt. |
---|
Browserunterstützung
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Unterstützt | 10.0 | Unterstützt | Unterstützt | Unterstützt |
Hinweis:Das Element <input type="month"> zeigt in Firefox keine Datumsfelder/Kalender an.