<!DOCTYPE html>
<html>
<body>

Password: <input type="password" id="myPsw" value="thgrt456">

<p>Click the button to select the content of the password field.</p>

<button type="button" onclick="myFunction()">Try it</button>

<script>
function myFunction() {
    document.getElementById("myPsw").select();
}
</script>

</body>
</html>