title: Copy text on click and display small popup afterwards - extending the code
body: <p>I need a little script that will allow me to copy text string on click <em>without a button</em>. </p>
  
  <p>I found this code: </p>
  
  <pre><code>function copy(that){
  var inp =document.createElement('input');
  document.body.appendChild(inp)
  inp.value =that.textContent
  inp.select();
  document.execCommand('copy',false);
  inp.remove();
  }
  </code></pre>
  
  <p>The code copies a text on click, but it doesn't show any message. I would like to modify it a little so when user click on text it will be copied and show a little popup message for 2-3 (then it should dissapear by itself) seconds saying that the text has been copied to clipboard. Does anyone have any idea how to modify the code that way?</p>
  
  <p><code>&lt;p onclick="copy(this)"&gt;example text&lt;/p&gt;</code> - that's how it recognizes which code to copy.</p>