<html>
<input type="text" value="Hello world"(Can be of your choice) id="myInput"(id is the name of the text, you can change it later)
<button onclick="Hello()">Copy Text</button>
<script>
function Hello() {
var copyText = document.getElementById('myInput')
copyText.select();
document.execCommand('copy')
console.log('Copied Text')
}
</script>
navigator.clipboard.writeText('the text')
<input type="text" placeholder="Create Password" id="text" readonly>
<script>
function copyPassword(){
var copyText = document.getElementById('text')
copyText.select()
copyText.setSelectionRange(0, 999)
document.execCommand("copy")
console.log(copyText);
}
</script>