Reset form 属性

定义和用法
form 属性可返回对包含该重置按钮的表单的引用。
若成功,该属性返回一个表单对象。
语法
resetObject.form
浏览器支持
所有主要浏览器都支持 form 属性
实例
实例
显示重置按钮所属表单的 id:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>KuJson教程(www.w3cmap.com)</title>
<script>
function displayResult(){
var x=document.getElementById("reset1").form.id;
alert(x);
}
</script>
</head>
<body>
<form id="form1">
Email: <input type="text" id="email">
<input type="reset" id="reset1">
</form>
<button type="button" onclick="displayResult()">显示所属的表单ID</button>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>KuJson教程(www.w3cmap.com)</title>
<script>
function displayResult(){
var x=document.getElementById("reset1").form.id;
alert(x);
}
</script>
</head>
<body>
<form id="form1">
Email: <input type="text" id="email">
<input type="reset" id="reset1">
</form>
<button type="button" onclick="displayResult()">显示所属的表单ID</button>
</body>
</html>
尝试一下 »
