The read onlyform
property get the form containing the time field.
form |
Yes | Yes | Yes | Yes | Yes |
var v = timeObject.form
A reference to the form element containing the time field. If the time field is not in a form, null is returned.
The following code shows how to get the id of the form containing the <input type="time"> element.
<!DOCTYPE html>
<html>
<body>
<!--from w w w . j av a 2 s . com-->
<form id="myForm">
Time: <input type="time" id="myTime">
</form>
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<script>
function myFunction() {
var x = document.getElementById("myTime").form.id;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>
The code above is rendered as follows: