I am trying to write an editor with contenteditable and execCommand. Everything works fine in Firefox, but in chrome there is an error with the "delete" command.
Please view the following photo:

This is my code:
var $obj = $('#myBlockDivId'); var selection = rangy.getSelection(); if (selection.rangeCount > 0) selection.removeAllRanges(); var range = rangy.createRange(); range.selectNode($obj[0]); selection.addRange(range); range.select();
when i console log: rangy.getSelection (). toHtml () ==> it right
but when i call:
document.execCommand("delete", null, false);
this is good for Firefox, but not correct in Chrome, the wrapper div is not removed.
How can i fix this? I have to use execCommand because it supports undo and redo function. so i cant use jquery or javascript dom selector to remove div.
(I'm bad in English, someone, please edit my question for a clearer, thank you very much)
source share