title: how to make a copy to clipboard button with js
body: <p>so i was trying to make a button that when clicked it copy a value from a variable</p>
  <p>like</p>
  <pre><code>&lt;button onclick=&quot;copyToClipboard()&quot;&gt;COPY&lt;/button&gt;
  </code></pre>
  <p>and then on that function it takes the element to copy from a variable like</p>
  <pre><code>var copyids = {
  &quot;ids&quot;: [
  {
  &quot;name&quot;: &quot;id1&quot;,
  &quot;id&quot;: 192389021
  },
  {
  &quot;name&quot;: &quot;id2&quot;,
  &quot;id&quot;: 123879032
  },
  {
  &quot;name&quot;: &quot;id3&quot;,
  &quot;id&quot;: 149018292
  },
  ]
  };
  </code></pre>
  <p>so like <code>copyids.ids[0].id</code> and it copy that value</p>
  <p>i hope its understandable</p>