Input Month name Property - Change the name of a month field: - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Month

Description

Input Month name Property - Change the name of a month field:

Demo Code

ResultView the demo in separate window

<!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() {// w ww .j  a v  a 2 s  . c  om
    var x = document.getElementById("myMonth").name = "newMonthName";
    console.log("The name was changed to: " + x);
}
</script>
</body>
</html>

Related Tutorials