Input Month value Attribute
Definition and Usage
value
Sets or returns the value of the month field's value attribute.
The HTML value attribute specifies the month and year of the month field.
See also:
HTML Reference Manual:Propriedade value do <input> em HTML
Example
Example 1
Set the month and year of the month field:
document.getElementById("myMonth").value = "2023-06";
Example 2
Get the month and year of the month field:
var x = document.getElementById("myMonth").value;
Example 3
An example showing the difference between the defaultValue and value attributes:
var x = document.getElementById("myMonth"); var defaultVal = x.defaultValue; var currentVal = x.value;
Syntax
Return the value attribute:
monthObject.value
Set the value attribute:
monthObject.value = YYYY-MM
Attribute value
Value | Description |
---|---|
YYYY-MM |
Define the month and year. Descrição do componente:
|
Detalhes técnicos
Retorno: | Valor de string, que representa o mês e o ano do campo do mês. |
---|
Suporte ao navegador
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Suporte | 10.0 | Suporte | Suporte | Suporte |
Atenção:O elemento <input type="month"> não exibe nenhum campo de data ou calendário no Firefox.