I have this code where I place the text cursor in a block of text
<h2 id="textareaEdit" contenteditable="true">
  text text text<br>text text text<br>
</h2>
<button onclick="textPlace()">focus</button>
<script>
function textPlace() {
  var el = document.getElementById("textareaEdit");
  var range = document.createRange();
  var sel = window.getSelection();
  range.setStart(el.childNodes[2], 5);
  range.collapse(true);
  sel.removeAllRanges();
  sel.addRange(range);
  el.focus();
}
</script>
I was wondering if there was a way to save the location of the text cursor when the user types and then they click off to another part of the page and then press a button to go back to the same spot.
Any ideas on how to do this? I've been trying to do this for a few days now and can't seem to get any code to save the location of the cursor
