Password type属性
Password オブジェクト定義と用法
type 属性はフォーム要素のタイプを返すことができます。
パスワードフィールドの場合、この属性は常に "password" です。
语法
passwordObject.type
浏览器支持
![]()
![]()
![]()
![]()
![]()
すべての主要ブラウザは type 属性をサポートしています。
实例
实例
以下の例は、そのパスワードフィールドのフォーム要素のタイプを返します。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>サンプル(example.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>
<html>
<head>
<meta charset="utf-8">
<title>サンプル(example.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 オブジェクト 其他扩展