Javascript examples for DOM HTML Element:Input Month
The name property sets or gets the name attribute of a month field.
Set the name property with the following Values
Value | Description |
---|---|
name | Sets the name of the month field |
A String, representing the name of the month field
The following code shows how to get the name of a month field:
<!DOCTYPE html> <html> <body> Birthday (month and year): <input type="month" id="myMonth" name="bdaymonth"> <button onclick="display()">Display name</button> <button onclick="change()">Change name</button> <script> function display() { var x = document.getElementById("myMonth").name; console.log("The name of the month field is: " + x); } function change() {//from w w w . jav a 2 s . c o m var x = document.getElementById("myMonth").name = "newMonthName"; console.log("The name was changed to: " + x); } </script> </body> </html>