คุณสมบัติแบบฟอร์ม HTML DOM Legend ส่งคืนการอ้างอิงของแบบฟอร์มที่ล้อมรอบสำหรับแท็ก Legend
ไวยากรณ์
ต่อไปนี้เป็นไวยากรณ์ -
ส่งคืนการอ้างอิงไปยัง แบบฟอร์ม วัตถุ
legendObject.form
ตัวอย่าง
เรามาดูตัวอย่าง รูปแบบตำนาน ทรัพย์สิน −
<!DOCTYPE html>
<html>
<head>
<title>Legend 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 id="legendForm">Legend-form</legend>
<label for="WeekSelect">Examination Week:
<input type="week" 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 legendForm = document.getElementById("legendForm");
function showExamination() {
divDisplay.textContent = 'Examinations: '+legendForm.form.id;
}
</script>
</body>
</html> ผลลัพธ์
สิ่งนี้จะสร้างผลลัพธ์ต่อไปนี้ -
ก่อนคลิก 'สัปดาห์นี้มีสอบอะไรบ้าง' ปุ่ม −

หลังจากตรวจสอบ 'สัปดาห์นี้มีสอบอะไรบ้าง' ปุ่ม −
