function copyToClipboard(element) { var $temp = $("<input>"); $("body").append($temp); $temp.val($(element).html()).select(); document.execCommand("copy"); $temp.remove(); }