Javascript DOM HTML Input DatetimeLocal name Property get

Introduction

Get the name of a local datetime field:

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

Click the button to display the value of the name attribute of the local datetime field.

View in separate window

<!DOCTYPE html>
<html>
<body>

Birthday: <input type="datetime-local" id="myLocalDate" name="bdaytime">

<button onclick="myFunction()">Test</button>
<p id="demo"></p>

<script>
function myFunction() {/*  w  w  w  .j  av  a  2s. c  om*/
  var x = document.getElementById("myLocalDate").name;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

The name property sets or gets the name attribute of a local datetime field.

The name attribute can identify form data after submitting to the server.

The name property accepts and returns a String type value.

The name property returns a String representing the name of the local datetime field.




PreviousNext

Related