Latest web development tutorials

HTML DOM Password form 屬性

Password 對象參考手冊 Password對象

定義和用法

form 屬性可返回對包含該密碼域的表單的引用。

該屬性將返回一個表單對象。

語法

passwordObject.form


瀏覽器支持

Internet ExplorerFirefoxOperaGoogle ChromeSafari

所有主要瀏覽器都支持form 屬性


實例

實例

下面的例子取得了該密碼域所屬的表單的id:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</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 對象參考手冊 Password對象