Skip to content

Instantly share code, notes, and snippets.

@NickyAlan
Created April 25, 2022 09:23
Show Gist options
  • Save NickyAlan/f209788bd14f826512004323ea30bd14 to your computer and use it in GitHub Desktop.
Save NickyAlan/f209788bd14f826512004323ea30bd14 to your computer and use it in GitHub Desktop.
<div class="fromspeech">
<div class="from1">
<div id="div11">{{speech}}</div>
<button id="button1" onclick="CopyToClipboard('div11')">Click to copy</button>
</div>
<div class="from1">
<div id="div12">{{result}}</div>
<button id="button2" onclick="CopyToClipboard('div12')">Click to copy</button>
</div>
</div>
<script>
function CopyToClipboard(containerid) {
if (document.selection) {
var range = document.body.createTextRange();
range.moveToElementText(document.getElementById(containerid));
range.select().createTextRange();
document.execCommand("copy");
} else if (window.getSelection) {
var range = document.createRange();
range.selectNode(document.getElementById(containerid));
window.getSelection().addRange(range);
document.execCommand("copy");
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment