1<html>
2 <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)
3<button onclick="Hello()">Copy Text</button>
4
5<script>
6 function Hello() {
7 var copyText = document.getElementById('myInput')
8 copyText.select();
9 document.execCommand('copy')
10 console.log('Copied Text')
11}
12</script>
1document.getElementById("cp_btn").addEventListener("click", copy_password);
2
3function copy_password() {
4 var copyText = document.getElementById("pwd_spn");
5 var textArea = document.createElement("textarea");
6 textArea.value = copyText.textContent;
7 document.body.appendChild(textArea);
8 textArea.select();
9 document.execCommand("Copy");
10 textArea.remove();
11}