Skip to content

Instantly share code, notes, and snippets.

@onuproy
Created July 21, 2019 05:06
Show Gist options
  • Save onuproy/c80d1ed2c863b5bac89ba610d61a8a1d to your computer and use it in GitHub Desktop.
Save onuproy/c80d1ed2c863b5bac89ba610d61a8a1d to your computer and use it in GitHub Desktop.
Copy Text to Clipboard
<!DOCTYPE html>
<html>
<body>
<p>Click on the button to copy</p>
<input type="text" value="Hello World" id="myInput">
<button onclick="myFunction()">Copy text</button>
<p>The document.execCommand() method is not supported in IE8 and earlier.</p>
<script>
function myFunction() {
var copyText = document.getElementById("myInput");
copyText.select();
document.execCommand("copy");
alert("Copied the text: " + copyText.value);
}
</script>
</body>
</html>
@onuproy
Copy link
Author

onuproy commented Jul 21, 2019

It's code is very helpful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment