title: set cursor position in textBox javascript
body: <p>I am trying to add new line to textBox and update textBox value with new line character in JavaScript using following code:</p>
  
  <pre><code>ele.value = ele.value + "\n";
  
  ele.focus();
  
  // To update cursor position to recently added character in textBox
  ele.setSelectionRange(value.length, value.length);
  </code></pre>
  
  <p>Above code updates textBox value but doesn't update cursor position to new line.</p>
  
  <p>(Though it updates cursor position when I click outside of textBox and again click inside textBox, but not when textBox is already being edited by user.)</p>