DOM图例表单属性用于返回对包含标记的表单的引用。这是只读属性,成功时将返回表单对象。
用法:
legendObject.form
例:本示例返回一个表单属性。
DOM Legend form Propertyform {
width:50%;
}
label {
display:inline-block;
float:left;
clear:left;
width:90px;
margin:5px;
text-align:left;
}
input[type="text"] {
width:250px;
margin:5px 0px;
}
.gfg {
font-size:40px;
color:green;
font-weight:bold;
}
GeeksforGeeks
DOM Legend Form Property
STUDENT::
Name:
Email:
Date of birth:
Address:
Enroll No:
Submit
function myGeeks() {
// Accessing legend tag
var g =
document.getElementById("GFG").form.id;
document.getElementById(
"sudo").innerHTML = g;
}
输出:
在单击按钮之前:
单击按钮后:
支持的浏览器:
谷歌浏览器
火狐浏览器
Edge
Opera
Safari