title: Auto select text when clicked
body: <p>I've made a div with some dummytext in it and I want all the dummytext to be selected when clicked on the div (instead of three clicks to select all, I want one). I've got the correct code to catch the mouseclick, but I can't find the right code to select the text.</p>
  <p>I tested the first part of the code with an alert and it worked.</p>
  <pre><code>&lt;div id=&quot;tekstveld&gt;
  dummytext with two paragraphs
  &lt;/div&gt;
  </code></pre>
  <p>JS:</p>
  <pre><code>$(document).ready(function(){
  $('#tekstveld').on('click', function(e){
      //some code to autoselect all the text in the div, I don't know })
  })
  </code></pre>
  <p>I'm using Jquery 3.5.1.</p>
  <p>Edit: answer found:</p>
  <p>Thanks, as natel said. I had to change the div to a input text (same as YouTube with the option to embed code).</p>
  <p>HTML:</p>
  <pre><code>&lt;input readonly type=&quot;text&quot; id=&quot;tekstveld&quot; value=&quot;Click Here To Copy This Text to Clipboard&quot; readonly&gt;
  </code></pre>
  <p>JS:</p>
  <pre><code>$(document).ready(function(){
  $('#tekstveld').on('click', function(e){
      this.select();});})
  </code></pre>