HTML DOM Password select() 方法
定義和用法
select() 方法用於選取密碼域中的文本
語法
passwordObject.select()
瀏覽器支持
所有主要瀏覽器都支持select() 方法
實例
實例
下面的例子可選取密碼域中的文本:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
<script>
function myFunction(){
document.getElementById("pwd").select();
}
</script>
</head>
<body>
<form>
密碼: <input type="password" id="pwd" value="thgrt456">
</form>
<button type="button" onclick="myFunction()">選中內容</button>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
<script>
function myFunction(){
document.getElementById("pwd").select();
}
</script>
</head>
<body>
<form>
密碼: <input type="password" id="pwd" value="thgrt456">
</form>
<button type="button" onclick="myFunction()">選中內容</button>
</body>
</html>
嘗試一下»
Password對象