Latest web development tutorials

HTML DOM Input Month value property

Input Month Object Reference Input Month Object

Examples

Set the month field of the year and month:

document.getElementById("myMonth").value = "2014-02";

try it"

Definition and Usage

value attribute is used to set the property value or return value month field.

value attribute describes the year and month month field.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support attribute value

Note: Internet Explorer or Firefox browser does not support type = "month" <input> element attributes.


grammar

Returns the value property:

monthObject .value

Set the value property:

monthObject .value=YYYY-MM

Property Value

描述
YYYY-MM 描述了年和月。实例解析:
  • YYYY - 年 (例如:2011)
  • MM - 月 (例如: 01 为 1月)

technical details

return value: String representing the year and month of month field


More examples

Examples

Get month field of the year and month:

var x = document.getElementById("myMonth").value;
x The output is:
1997-11

try it"


Related Pages

HTML Reference Manual: HTML <the INPUT> value The property


Input Month Object Reference Input Month Object