HTML DOM 图例 form 属性
HTML DOM 图例 form 属性返回 legend 标签关联表单的引用。
语法
以下是语法 −
返回对form 对象的引用
legendObject.form
示例
让我们看一个图例 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>输出
将产生以下输出 −
点击‘本周有哪些考试?’按钮之前 −

选中‘本周有哪些考试?’按钮之后 −

广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP