2017:
Try this Magic answer from ContentEditable field and Range
var range = document.createRange(); // create range selection range.selectNodeContents($element); // select all content of the noderange.deleteContents() // maybe there is replace command but i'm not find itrange.insertNode(frag)