views:

69

answers:

1

hi, i have range>

newNode = document.createElement("span");
newNode.innerHTML = 'example';
range.insertNode(newNode);

i insert new node. is there way, how to automatically select this newNode (as it appears on page, it is not selected) ? thanks.

+1  A: 
range.selectNodeContents(newNode);
var sel = window.getSelection();
sel.removeAllRanges();
sel.addRange(range);
Tim Down