Select the content of a password field:
Click the button to select the content of the password field.
<!DOCTYPE html> <html> <body> Password: <input type="password" id="myPsw" value="password123"> <button type="button" onclick="myFunction()">Test</button> <script> function myFunction() {/* w w w .j av a 2 s .c om*/ document.getElementById("myPsw").select(); } </script> </body> </html>
The select()
method is used to select the content of a password field.
select();