Is there a simple js function I can use to replace the current document\'s selection with some html of mine?
For instance say the document contains a
You can use the Rangy library http://code.google.com/p/rangy/
You can then do
var sel = rangy.getSelection(); var range = sel.getRangeAt(0); range.deleteContents(); var node = range.createContextualFragment('hoho'); range.insertNode(node);