 <p>You can do it like this:</p> <pre><code>function setCaret() { var element = document.getElementById("input"); var range = document.createRange(); var node; node = document.getElementById("first"); range.setStart(node.childNodes[0], 1); &lt;-- sets the location var sel = window.getSelection(); range.collapse(true); sel.removeAllRanges(); sel.addRange(range); element.focus(); } </code></pre> <p>node.childNodes[] pertains to which line you want to set the cursor on and the next number is the location on that line. In this example is moves to space 1 line 0 (line 1 really). So if you change those values to variables and put them as parameters in your function you could specify where.</p>