HTML DOM Password size 屬性
定義和用法
size 屬性可設置或者返回密碼域的的寬度(數字字符)。
默認值為20。
語法
設置size 屬性:
passwordObject.size=integer
返回size 屬性:
passwordObject.size
瀏覽器支持
所有主要瀏覽器都支持size 屬性
實例
實例
設置密碼域的寬度:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
<script>
function setResult(){
document.getElementById("pwd").size=40;
}
</script>
</head>
<body>
<form>
密碼: <input type="password" id="pwd">
</form>
<button type="button" onclick="setResult()">設置寬度</button>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
<script>
function setResult(){
document.getElementById("pwd").size=40;
}
</script>
</head>
<body>
<form>
密碼: <input type="password" id="pwd">
</form>
<button type="button" onclick="setResult()">設置寬度</button>
</body>
</html>
嘗試一下»
Password對象