JavaScript 参考手册教程
HTML DOM Password form 属性
HTML DOM Password form 属性
Password form 属性
Password 对象定义和用法
form 属性可返回对包含该密码域的表单的引用。
该属性将返回一个表单对象。
语法
passwordObject.form
浏览器支持
所有主要浏览器都支持 form 属性
实例
实例
下面的例子取得了该密码域所属的表单的 id:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>非常教程(verydoc.net)</title>
<script>
function displayResult(){
var x=document.getElementById("pwd").form.id;
alert(x);
}
</script>
</head>
<body>
<form id="form1">
密码: <input type="password" id="pwd">
</form>
<button type="button" onclick="displayResult()">显示所属的表单id</button>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>非常教程(verydoc.net)</title>
<script>
function displayResult(){
var x=document.getElementById("pwd").form.id;
alert(x);
}
</script>
</head>
<body>
<form id="form1">
密码: <input type="password" id="pwd">
</form>
<button type="button" onclick="displayResult()">显示所属的表单id</button>
</body>
</html>
尝试一下 »
Password 对象
HTML DOM Password form 属性 |
---|
JavaScript 参考手册
JavaScript 参考手册提供了完整的 JavaScript 对象、浏览器对象、HTML DOM 对象手册。手册包含了每个对象、属性、方法的实例。