title: Javascript: Move caret to last character
body: <p>I have a textarea and when I click in it I want to move the caret to the last character so <code>Something[caret]</code></p>
  
  <pre class="lang-js prettyprint-override"><code>function moveCaret(){
       // Move caret to the last character
  }
  </code></pre>
  
  <pre class="lang-html prettyprint-override"><code>&lt;textarea onclick="moveCaret();"&gt;
       Something
  &lt;/textarea&gt;
  </code></pre>
  
  <p>As I know this is somehow possible with the TextRange object, but I don't really know how to use it</p>
  
  <p><strong>EDIT:</strong> I would love to see only pure javascript solutions so no libraries please.</p>