Password select() 方法

Password 对象参考手册 Password 对象

定义和用法

select() 方法用于选取密码域中的文本

语法

passwordObject.select()


浏览器支持

Internet ExplorerFirefoxOperaGoogle ChromeSafari

所有主要浏览器都支持 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>

尝试一下 »


Password 对象参考手册 Password 对象