Đối tượng Legend trong HTML DOM đại diện cho phần tử <legend>.
Cú pháp
Tạo một phần tử <legend>:
var legendObject = document.createElement("LEGEND")
Các thuộc tính
Đối tượng LegendObject có thể có các thuộc tính sau:
| Thuộc tính | Mô tả |
|---|---|
| form | Trả về tham chiếu đến form bao quanh chứa phần tử legend |
Ví dụ
Ví dụ minh họa thuộc tính Legend 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">Tuần thi cử: <input type="week" value="2019-W36"> </label> <input type="button" onclick="showExamination()" value="Tuần này thi môn gì? "> <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>
Kết quả
Trước khi nhấn nút 'Tuần này thi môn gì?':

Sau khi kiểm tra nút 'Tuần này thi môn gì?':
