CosminV of Technical Support
5/7/2020 - 12:45 PM

Click to copy button

Click to copy button

Example page: http://clicktocopybutton.pagedemo.co/

<script>
document.addEventListener("DOMContentLoaded", function() {
    var buttonId = 'element-1';
    var textToCopy = 'aladin';
    document.getElementById(buttonId).addEventListener("click", function() {
        document.getElementsByTagName("body");
        var input = document.createElement("input");
        document.body.appendChild(input);
        input.value = textToCopy;
        input.select();
        document.execCommand("copy");
        input.parentNode.removeChild(input);
    });
});
</script>