HTML DOM 輸入周表單屬性


HTML DOM 輸入周表單屬性返回輸入周的封閉表單的引用。

語法

以下是語法 −

返回指向表單物件的引用

inputWeekObject.form

示例

下面我們來看一個輸入周表單屬性的示例 −

 即時演示

<!DOCTYPE html>
<html>
<head>
<title>Input Week 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="Mid-Term">
<fieldset>
<legend>Week-form</legend>
<label for="WeekSelect">Examination Week:
<input type="week" id="WeekSelect" value="2019-W36">
</label>
<input type="button" onclick="showExamination()" value="What exams are in this week? ">
<div id="divDisplay"></div>
</fieldset>
</form>
<script>
   var divDisplay = document.getElementById("divDisplay");
   var inputWeek = document.getElementById("WeekSelect");
   function showExamination() {
      divDisplay.textContent = 'Examinations: '+inputWeek.form.id;
   }
</script>
</body>
</html>

輸出

它將產生以下輸出 −

在點選‘本週有什麼考試?’按鈕之前 −

在勾選‘本週有什麼考試?’按鈕之後 −

更新時間: 2019 年 7 月 30 日

83 次瀏覽

開啟你的職業之旅

完成課程以獲得認證

開始
廣告
© . All rights reserved.