title: javascript text editor - how to capture selection
body: <p>I'm trying to write a simple web text editor.
  what I want to do is let the user type on a textarea (or a textarea-like input) and select text with the mouse or with shift key and click a button to apply a color based effects.
  my questions are such:</p>
  
  <ol>
  <li>how do I capture the selection in a way it's not lost when the
  button is clicked  </li>
  <li>how to save the text and the selection</li>
  <li>how to make it WYSIWYG</li>
  </ol>
  
  <p>p.s. I don't want a full rich text editor. I need only one effect</p>
  
  <p>thanks</p>