output in Chrome:
hey
&
If you are using the google closure compiler, you can do the following (somewhat simplified from Tim's answer):
function placeCaretAtEnd(el) {
el.focus();
range = goog.dom.Range.createFromNodeContents(el);
range.collapse(false);
range.select();
}
Here's the same thing in ClojureScript:
(defn place-caret-at-end [el]
(.focus el)
(doto (.createFromNodeContents goog.dom.Range el)
(.collapse false)
.select))
I have tested this in Chrome, Safari and FireFox, not sure about IE...