How we can implement copy to clipboard feature on button click in NodeJs using express handlebar template.
I have tried using Javascript but it's not working.
Below is the code which I have tried:
myFile.handlebars :
<input type="button" id="linkBtn" class="btn btn-primary" onclick="copyLink()" data-toggle="tooltip" title="Copy to Clipboard" value="copy link" readonly />
<script>
function copyLink() {
let copyText = document.getElementById("linkBtn");
/* Select the text field */
copyText.select();
/* Copy the text inside the text field */
document.execCommand("copy");
/* Alert the copied text */
//alert("Copied the text: " + copyText.value);
}
</script>