title: how do I get co-ordinates of selected text in an html using javascript document.getSelecttion()
body: <p>I would like to position element above selected text. But I am not able to figure out the coordinates.</p>
  
  <pre><code>var sel = document.getSelection();
    if(sel != null) {
      positionDiv();
  }
  </code></pre>
  
  <p>Example: (image)</p>
  
  <p><a href="https://i.stack.imgur.com/QLOeU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QLOeU.png" alt="alt text"></a>
  </p>