📜  删除了 Selection.addRange() 合并现有 Range 和指定 Range 的行为. - Javascript代码示例

📅  最后修改于: 2022-03-11 15:03:23.348000             🧑  作者: Mango

代码示例1
#make sure to call selection.removeAllRanges(), then call selection.addRange(range)
selection = window.getSelection();    
range = document.createRange();
range.selectNodeContents(elem);
selection.removeAllRanges();         
selection.addRange(range);