Input Month name attribute

Definition and Usage

name Set or return the value of the name attribute of the month field.

The HTML name attribute is used to identify form data after form data is submitted to the server, or to reference form data on the client using JavaScript.

注意:Only form elements that have a name attribute will pass their values when submitting the form.

See also:

HTML Reference Manual:HTML <input> name 属性

Example

Example 1

Get the name of the month field:

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

Try it yourself

Example 2

Change the name of the month field:

document.getElementById("myMonth").name = "newMonthName";

Try it yourself

Syntax

Return name attribute:

monthObject.name

Set name attribute:

monthObject.name = name

属性值

描述
name 规定月份字段的名称。

技术细节

返回值: 字符串值,表示月字段的名称。

浏览器支持

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
支持 10.0 支持 支持 支持

注意:<input type="month"> 元素在 Firefox 中不显示任何日期字段/日历。