Set caret position in contenteditable div layer in Chrome/webkit
- by Alex
Hello,
I'm trying to set the caret position in a contenteditable div layer, and after a bit of searching the web and experimenting I got it to work in firefox using this:
function set(element,position){
element.focus();
var range= window.getSelection().getRangeAt(0);
range.setStart(element.firstChild,position);
…