Positioning caret in content editable ReactJS components. You will most likely need to run this in the componentDidMount() method. Hope that helps. Here is a rough idea of what it would look like:
1 2 3 4 5 6 7 8 9 10 11 | componentDidMount: function () { var el = document.getElementById("a3"); var range = document.createRange(); var sel = window.getSelection(); range.setStart(el.childNodes[0], 1); range.collapse(true); sel.removeAllRanges(); sel.addRange(range); el.childNodes[0].focus(); }, |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.