Password select() 方法

定义和用法
select() 方法用于选取密码域中的文本
语法
passwordObject.select()
浏览器支持
所有主要浏览器都支持 select() 方法
实例
实例
下面的例子可选取密码域中的文本:
<html>
<head>
<script>
function myFunction()
{
document.getElementById("pwd").select();
}
</script>
</head>
<body>
<form>
Password: <input type="password" id="pwd" value="thgrt456">
</form>
<button type="button" onclick="myFunction()">Select content</button>
</body>
</html>
<head>
<script>
function myFunction()
{
document.getElementById("pwd").select();
}
</script>
</head>
<body>
<form>
Password: <input type="password" id="pwd" value="thgrt456">
</form>
<button type="button" onclick="myFunction()">Select content</button>
</body>
</html>
尝试一下 »

更多建议: