Javascript DOM HTML Input Time name Property get

Introduction

Get the name of a time field:

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

Click the button to display the value of the name attribute of the time field.

View in separate window

<!DOCTYPE html>
<html>
<body>

Time: <input type="time" id="myTime" name="usr_time">
<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {/*from ww  w .j a  v a2s. c o m*/
  var x = document.getElementById("myTime").name;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

The name property sets or gets the value of the name attribute of a time field.

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

Only form elements with a name attribute will be submitted to the server.

The <input type="time"> element is not supported in Firefox.

The name property accepts and returns a String type value.

Value Description
name Specifies the name of the time field

The name property returns a String representing the name of the time field.




PreviousNext

Related