HTML DOM 图例 form 表单属性
htmlweb developmentfront end technology更新于 2025/7/11 15:40:17
HTML DOM 图例表单属性返回图例标签所包含表单的引用。
语法
以下是语法 −
返回对 form 对象的引用
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>
输出
这将产生以下输出 −
在点击"本周有哪些考试?"按钮之前 −

在检查"本周有哪些考试?"按钮后 −

相关文章
有用资源
html 参考教程 - 该教程包含有关 html 的更多信息:https://www.cainiaomax.com/html/

