【无标题】如何在range取得select的文本

求助

    var selection = document.getSelection();
    var range = selection.getRangeAt(0);
    var startoffset = range.startOffset;
    var endoffset = range.endOffset;
    var nodeText = range.startContainer;
    var nodeText2 = range.endContainer;

    console.log("start location:", startoffset);
    console.log("end location:", endoffset);
    console.log(nodeText);
    console.log(nodeText2);
    console.log(selection);

range.startContainer获取的是标签和标签之间的整个段落

【无标题】如何在range取得select的文本_第1张图片

document.getSelection();

【无标题】如何在range取得select的文本_第2张图片

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!哪里有完整Api文档看!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

你可能感兴趣的:(笔记,php)