📅  最后修改于: 2022-03-11 15:03:23.348000             🧑  作者: Mango
#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);