jquery copy to clipboard hidden field code example
Example 1: copy text to clipboard jquery
function copyToClipboard(element) {
var $temp = $("<input>");
$("body").append($temp);
$temp.val($(element).html()).select();
document.execCommand("copy");
$temp.remove();
}
Example 2: js select and copy on click
document.getElementById("copy-text").onclick = function() {
this.select();
document.execCommand('copy');
alert(window.getSelection().toString());
}