คุณสมบัติแบบฟอร์มเดือนที่ป้อน HTML DOM ส่งกลับการอ้างอิงของแบบฟอร์มที่มีฟิลด์ป้อนข้อมูลเดือนในเอกสาร HTML
ไวยากรณ์
ต่อไปนี้เป็นไวยากรณ์ -
object.form
ตัวอย่าง
ให้เราดูตัวอย่างของคุณสมบัติแบบฟอร์มเดือนที่ป้อน HTML DOM -
<!DOCTYPE html>
<html>
<head>
<style>
body{
text-align:center;
background-color:#363946;
color:#fff;
}
form{
margin:2.5rem auto;
}
button{
background-color:#db133a;
border:none;
cursor:pointer;
padding:8px 16px;
color:#fff;
border-radius:5px;
font-size:1.05rem;
outline:none;
}
.show{
font-weight:bold;
font-size:1.4rem;
}
</style>
</head>
<body>
<h1>form Property Demo</h1>
<form id="Form 1">
<fieldset>
<legend>Form 1</legend>
<input type="month" class="monthInput">
</fieldset>
</form>
<button onclick="identify()">Identify Month Input Field</button>
<p class="show"></p>
<script>
function identify() {
var formId = document.querySelector(".monthInput").form.id;
document.querySelector(".show").innerHTML = "Hi! I'm from " + formId;
}
</script>
</body>
</html> ผลลัพธ์
สิ่งนี้จะสร้างผลลัพธ์ต่อไปนี้ -

คลิกที่ปุ่ม “ระบุช่องป้อนข้อมูลเดือน” เพื่อรับแบบฟอร์มที่มีช่องใส่เดือน
