HTML DOM Input Time form 属性

htmlweb developmentfront end technology更新于 2025/8/4 5:32:17

HTML DOM Input Time form 属性返回用于输入时间的封闭表单的引用。

语法

以下是语法 −

返回对 form 对象的引用

inputTimeObject.form

示例

让我们看一个 Input Time form 属性的示例 −

<!DOCTYPE html>
<html>
<head>
<title>Input Time form</title>
<style>
   form {
      width:70%;
      margin: 0 auto;
      text-align: center;
   }
   * {
      padding: 2px;
      margin:5px;
   }
   input[type="button"] {
      border-radius: 10px;
   }
</style>
</head>
<body>
<form id="Physics">
<fieldset>
<legend>Time-form</legend>
<label for="TimeSelect">Examination Time :
<input type="time" id="TimeSelect" value="14:00" disabled>
</label>
<input type="button" onclick="getform()" value="Which Exam?">
<div id="divDisplay"></div>
</fieldset>
</form>
<script>
   var divDisplay = document.getElementById("divDisplay");
   var inputTime = document.getElementById("TimeSelect");
   function getform() {
      divDisplay.textContent = inputTime.form.id+' exam starts from '+inputTime.value;
   }
</script>
</body>
</html>

输出

这将产生以下输出 −

点击"哪场考试?"按钮前 −

勾选"哪场考试?"按钮后 −


相关文章


有用资源