title: How to highlight and select text on mobile using JS
body: <p>I wish to highlight text on touchscreens. From the selected text (yellow) there should appear a popup (green)
  <a href="https://i.stack.imgur.com/QLDaZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QLDaZ.png" alt="highlight text in red box. Green box appears" /></a></p>
  <p>On desktop computers, using mouse, I can highlight and select text from the red box using functions <code>.on(&quot;mousedown&quot;)</code> and <code>.on(&quot;mouseup&quot;)</code></p>
  <pre><code>  $(&quot;body&quot;).on(&quot;mousedown&quot;, &quot;.redbox&quot;, async function(e) {
              DoSomething(e);               
      });
  </code></pre>
  <p>and</p>
  <pre><code>$(&quot;body&quot;).on(&quot;mouseup&quot;,&quot;.redbox&quot;, function(e) {
                  
          
          if (this.innerHTML != &quot;&quot;) {
              selectTextFromWindow(e);
          }
        
  
      });
  </code></pre>
  <p>However, I wish to do the same on mobile devices, and have not been succesful. I know it has something to do with touchevents, but since I am a copy-paste-kinda-guy and not a real developer, i have not been able to find a live example to copy from. Snippets are very much appreaciated!</p>