title: update textarea value, but keep cursor position
body: <p>I have an html textarea that will be updated periodically via javascript.</p>
  
  <p>when I do this:</p>
  
  <pre><code>$("#textarea").val(new_val);
  </code></pre>
  
  <p>The cursor moves to the end of the text.</p>
  
  <p>I would like to update the text without changing the cursor position. Also, if the user has a range of text selected, the highlight should be preserved.</p>