Import clipboard.js
Use as follows
<script> copyFn = function() { var clipboard = new Clipboard('.copy-btn', { text: function(trigger) { return $('.copy-txt').text(); } }); clipboard.on('success', function() { alert( ' Copy successfully! ' ); }); clipboard.on('error', function(e) { alert( ' Please manually select the invitation code to copy! ' ); }); } copyFn (); </script>