2017-04-14 143 views

回答

1

this Github issue,现在你有添加至您的选择之前调用removeAllRanges()

selection = window.getSelection(); // Save the selection. 
range = document.createRange(); 
range.selectNodeContents(elem); 
selection.removeAllRanges();   // Remove all ranges from the selection. 
selection.addRange(range);   // Add the new range.