Home  >  Article  >  Web Front-end  >  How to copy to clipboard with one click using jquery

How to copy to clipboard with one click using jquery

一个新手
一个新手Original
2017-09-29 09:56:132005browse


<p style="margin-top: 7px;">今天做项目有一个功能,通过点击事件复制一段文本到剪切板,在网上找了一些,整理了一下,方便需要的朋友使用。<br/><br/><a id="copy" data-text="123456">复制文本</a>$(function(){<br/>       var clipboard = new Clipboard(&#39;#copy&#39;,{  <br/><br/>              text: function(trigger) { <br/><br/>                   alert("复制成功!");<br/><br/>                   return trigger.getAttribute(&#39;data-text&#39;);  <br/><br/>              }<br/><br/>       });<br/>});</p>

The above is the detailed content of How to copy to clipboard with one click using jquery. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn