copy text in 1 click

Discussion in 'Off Topic' started by freefil2, Feb 3, 2019.

  1. freefil2

    freefil2 New Member

    Messages:
    1
    Likes Received:
    0
    Trophy 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
     

    Attached Files:

  2. gomarc

    gomarc Member

    Messages:
    516
    Likes Received:
    18
    Trophy 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/
     

Share This Page