Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML DOM Input Month value Property

Input Month value Property

Input Month Object Reference Input Month Object

Example

Set the year and month of the month field:

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

Try it »


Definition and Usage

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

The value property describes the year and month of the month field.


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the value attribute

**Note:** Internet Explorer or Firefox browsers do not support the HTML using the type="month" attribute .


Syntax

Return the value attribute:

monthObject

.value

Set the value attribute:

monthObject

.value=

YYYY-MM

Attribute values

Value Description
YYYY-MM Describes the year and month. Example analysis:
  • YYYY - year (e.g.: 2011)
  • MM - month (e.g.: 01 for January)
  • |

    Technical Details

    Return Value: String, representing the year and month of the month field

    More examples

    Example

    Get the year and month of the month field:

    var x = document.getElementById("myMonth").value;

    x

    The output is:

    1997-11

    Try it »


    Related pages

    HTML Reference Manual: HTML value attribute


    Input Month Object Reference Input Month Object