I have an html textarea that will be updated periodically via javascript.
when I do this:
$("#textarea").val(new_val);
The cursor moves to the end of the text.
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.