You could use my Rangy library, which attempts with some success to normalize browser range and selection implementations. If you’ve managed to insert the <a>
as you say and you’ve got it in a variable called aElement
, you can do the following:
var range = rangy.createRange();
range.setStartAfter(aElement);
range.collapse(true);
var sel = rangy.getSelection();
sel.removeAllRanges();
sel.addRange(range);