Latest web development tutorials

HTML DOM Password type 屬性

Password 對象參考手冊 Password對象

定義和用法

type 屬性可返回表單元素的類型。

對於密碼域,該屬性總是"password"。

語法

passwordObject.type


瀏覽器支持

Internet ExplorerFirefoxOperaGoogle ChromeSafari

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


實例

實例

下面的例子返回了該密碼域的表單元素類型:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
<script>
function displayResult(){
var x=document.getElementById("pwd").type;
alert(x);
}
</script>
</head>
<body>

<form>
密碼: <input type="password" id="pwd">
</form>
<button type="button" onclick="displayResult()">顯示input 類型</button>

</body>
</html>

嘗試一下»


Password 對象參考手冊 Password對象