title: Get parent element of a selected text
body: <p>Is it possible to get the parent element of a selected text in the page? For example:</p>
  
  <pre><code>&lt;div class="someparent"&gt;
  
  Selection of this text should refer to the 'someparent' class.
  
  &lt;span class="spanparent"&gt;If this is selected, the parent should be this span&lt;/span&gt;
  
  &lt;/div&gt;
  </code></pre>
  
  <p>Because when getting the selected text, it normally gets it from the window or the document (depending on the browser) but is it that possible to get the parent element of the selected text?</p>