title: copy text onclick from <p> tag
body: <pre><code>                          &lt;div class=&quot;d-flex flex-row justify-content-between&quot;&gt;
                              &lt;p class=&quot;mb-0 me-1 py-2 ps-4 add-text&quot; id=&quot;p1&quot;&gt;ygwbfewilskfhnewisfklnewiofjfhjky&lt;/p&gt;
                              &lt;button class=&quot;btn-primary w-20 px-3 copy-btn&quot; onclick=&quot;copyToClipboard('#p1')&quot;&gt;Copy&lt;i class=&quot;fa-regular fa-copy ps-2&quot;&gt;&lt;/i&gt;&lt;/button&gt;
                            &lt;/div&gt;
  </code></pre>
  <p>JS:</p>
  <pre><code>    function copyToClipboard(element) {
  var $temp = $(&quot;&lt;input&gt;&quot;);
  $(&quot;body&quot;).append($temp);
  $temp.val($(element).text()).select();
  document.execCommand(&quot;copy&quot;);
  $temp.remove();
  }
  </code></pre>
  <p>I want to copy the text in the p id=&quot;p1&quot;.</p>
  <p>I tried this method because I saw it work for someone else but it doesn't work for me</p>