Copy to Clipboard (Without Flash) Using Copy Command

You may also like...


  1. Alex says:

    cool script
    but how can I make it utilisable if I need several different elements to be copied in the same page??

    • Hendy Tarnando says:

      You can use the copyToClipboard function in the last example. For instance:

      <button id="button1" onclick="copyToClipboard(document.querySelector('#element1'))" type="button">Copy</button>
      <button id="button2" onclick="copyToClipboard(document.querySelector('#element2'))" type="button">Copy</button>

Leave a Comment

Wrap your code block in <pre class="code"></pre> tag.