Home > Article > Web Front-end > Copy text to clipboard with one click using jquery
There is a function in my project today. You can copy a piece of text to the clipboard by clicking a button. I found some on the Internet and sorted it out for the convenience of friends who need it.
<a id="copy" data-clipboard-text="123456">复制文本</a> $(function(){ var clipboard = new Clipboard('#copy',{ text: function(trigger) { alert("复制成功!"); return trigger.getAttribute('data-clipboard-text'); } }); });
The above is the detailed content of Copy text to clipboard with one click using jquery. For more information, please follow other related articles on the PHP Chinese website!