Copy Text Program Code

 <!DOCTYPE html>

<html>

<body>


<div align="center">


<p>Click "Copy Text" button to copy input text</p>


<input type="text" value="Hello World" id="myInput">

<button onclick="myFunction()">Copy Text</button>


</div>


<script>

function myFunction() {

  var copyText = document.getElementById("myInput");

  copyText.select();

  copyText.setSelectionRange(0, 99999)

  document.execCommand("copy");

  alert("Copied the text: " + copyText.value);


}

</script>


</body>

</html>


View Output

Comments

Popular posts from this blog

What is a Blogs? How to create account on Blog?

What is JAVASCRIPT?How to make a program using HTML and Java | "Hello World" | Prakhar Doneria

HOW TO ADD PIE CHART IN HTML | PRAKHAR DONERIA