Edit This Code:
See Result »
<!DOCTYPE html> <html> <body> <form id="myForm"> Time: <input type="time" id="myTime"> </form> <p>Click the button to return the id of the form the time field belongs to.</p> <button onclick="myFunction()">Try it</button> <p><strong>Note:</strong> elements with type="time" are not supported in Internet Explorer or Firefox.</p> <p id="demo"></p> <script> function myFunction() { var x = document.getElementById("myTime").form.id; document.getElementById("demo").innerHTML = x; } </script> </body> </html>
Result: