我想通过使用 Javascript 发送 location/anchorOffset 和 length/offset 来选择文本这是我的代码
var node = document.getElementById("content");
var range = document.createRange();
range.setStart(node, 0);
range.setEnd(node, 4); // here 0 and 4 is my location and length for the selection
// if my string is "This is test string" in my case its must select "This"
var selection = window.getSelection();
selection.removeAllRanges();
selection.addRange(range);
但问题在于 range.setStart 和 range.setEnd 它没有像我预期的那样工作