Password select()Method

Password 对象参考手册Password Object

Definition and Usage

The select() method is used to select the text in a password field.

Syntax

passwordObject.select()


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the select() method.


Example

Example

The following example selects the text in a password field:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Example (example.com)</title>
<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</button>

</body>
</html>

Try it yourself »


Password 对象参考手册Password Object Other Extensions