2017-04-14 130 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.