0

I have the following:

<div contenteditable="true">
    <p>Here is some text blah <span class="tag">meme</span> hello world.</p>
</div>

What I want to do is set the cursor after the span. I can use the following but this doesn't let me tell the cursor to go after the span:

    var sel = window.getSelection();
    var textNode = document.getElementById("comment_content_new").firstChild;
    var range = document.createRange();
    range.setStart(textNode, 7);
    range.collapse(true);
    sel.removeAllRanges();
    sel.addRange(range);

Any ideas how I can tell var textNode to go after the span?

Thanks

AnApprentice
  • 108,152
  • 195
  • 629
  • 1,012

1 Answers1

0

The easiest way would be with jquery

$("span").after(textNode);
u.k
  • 3,091
  • 1
  • 20
  • 23