let textPosition = document.getElementsByClassName(‘text‘)[0]; var range = window.getSelection();//创建range range.selectAllChildren(textPosition);//range 选择obj下所有子内容 range.collapseToStart();//光标移至最前 range.collapseToEnd();//光标移至最后
2021-08-11 00:40:55
let textPosition = document.getElementsByClassName(‘text‘)[0]; var range = window.getSelection();//创建range range.selectAllChildren(textPosition);//range 选择obj下所有子内容 range.collapseToStart();//光标移至最前 range.collapseToEnd();//光标移至最后