Input DatetimeLocal name Property - Change the name of a local datetime field: - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Datetime Local

Description

Input DatetimeLocal name Property - Change the name of a local datetime field:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>
Birthday: <input type="datetime-local" id="myLocalDate" name="bdaytime">

<button onclick="display()">Display name</button>
<button onclick="change()">Change name</button>

<script>
function display() {
    var x = document.getElementById("myLocalDate").name;
    console.log("The name of the local datetime field is: " + x);
}

function change() {/*  w w  w .jav a  2s  .c  o  m*/
    var x = document.getElementById("myLocalDate").name = "newDatetimeName";
    console.log("The name was changed to: " + x);
}
</script>
</body>
</html>

Related Tutorials