Site URL: https://www.capemademark.org/use-the-mark
Hi, I would like to create a button that copies HTML code to your clipboard for this page on my website: https://www.capemademark.org/use-the-mark
Visitors to the page must be able to copy the HTML code and paste it into code blocks on their own websites.
Here is the solution to copy TEXT to clipboard:
<p>Click copy to clipboard</p>
<input type="text" value="Hello World" id="myInput">
<button onclick="myFunction()">Copy text</button>
<script>
function myFunction() {
var copyText = document.getElementById("myInput");
copyText.select();
copyText.setSelectionRange(0, 99999)
document.execCommand("copy");
alert("Copied the text: " + copyText.value);
}
</script>