copy text in 1 click

freefil2

New Member
Messages
1
Reaction score
0
Points
1
quiero saber como hacer para copiar este texto con solo un click
upload_2019-2-3_21-5-28.png

Like this page here
upload_2019-2-3_21-6-7.png

This is my Code
upload_2019-2-3_21-8-58.png
 

Attachments

  • upload_2019-2-3_21-4-3.png
    upload_2019-2-3_21-4-3.png
    228.1 KB · Views: 2

gomarc

Member
Messages
516
Reaction score
18
Points
18
Hello freefil2,

You can copy text to clipboard with something like this:

HTML:
<!DOCTYPE html>
<html>
  <body>
   
  <h2>Example:</h2>
   
  <!-- 1. Define some markup -->
  <button class="btn"
  data-clipboard-text="unitysheepers.zapto.org">
  Copy to clipboard
  </button>

  <!-- 2. Include library -->
  <script src="https://cdn.jsdelivr.net/npm/clipboard@2/dist/clipboard.min.js"></script>

  <!-- 3. Instantiate clipboard by passing a list of HTML elements -->
  <script>
  var btns = document.querySelectorAll('button');
  var clipboard = new ClipboardJS(btns);
  clipboard.on('success', function(e) {
  console.log(e);
  });
  clipboard.on('error', function(e) {
  console.log(e);
  });
  </script>   
   
  </body>
</html>


To customize the script to your needs, please read more at https://clipboardjs.com/
 
Top