title: Javascript copy to clipboard when you don't know the ID
body: <p>I have a table with various columns, and I want the user to be able to copy text in a cell by clicking on it. This is dynamic content, so I don't know what the ID or class will be at the time.</p>
  <p>This works for me, but it will obviously not work because of <code>getElementById</code>. How could I do it so the copy works for the cell the use clicks on?</p>
  <pre><code>function copyAddress() {
      /* Get the text field */
      var copyText = document.getElementById(&quot;address&quot;);
  
      /* Select the text field */
      copyText.select();
      copyText.setSelectionRange(0, 99999); /* For mobile devices */
  
      /* Copy the text inside the text field */
      navigator.clipboard.writeText(copyText.value);
  }
  </code></pre>