title: Get currently selected text on page
body: <p>How would you get the currently selected text within a textarea (and modify it)?</p>
  
  <p>I've seen the select event that can be listened for, but I was wondering if there was a way to just get the currently selected text.</p>
  
  <p>Also, what technique do you need to use in order to be able to modify that specific section of text within the textarea? I assume there's some way of finding out what the position of the selection is within the contents of the textarea as a whole?</p>
  
  <p>What I want to be able to do is take the selection and modify it, or wrap it in certain tags etc., like you are able to do in the stackexchange text editor.</p>