$('[data-copy]').on('click', function() { var $temp = $("<input>"); $("body").append($temp); $temp.val($(this).text()).select(); document.execCommand("copy"); $temp.remove(); });