SOURCE

console 命令行工具 X clear

                    
>
console
function showInfo() {
        var sel = window.getSelection();
        var range = sel.getRangeAt(0);
        sel.collapseToEnd();
}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Selection API</title>
</head>
<body>
    <div id="box" contenteditable>
        <div onclick="showInfo()">
            <p id="first">这里是一段普通的 <span>文字</span>内容</p>
            <p id="second">这里是另一段普通的 <span id="third">文字内容啊</span></p>
            <p>这是一段带有英文的句子: this is a line with english</p>
            <p>这是一段带有英文的多行句子: this is a line with english。这是一段带有英文的多行句子: this is a line with english.这是一段带有英文的多行句子: this is a line with english,这是一段带有英文的多行句子: this is a line with english。这是一段带有英文的多行句子: this is a line with english。这是一段带有英文的多行句子: this is a line with english。这是一段带有英文的多行句子: this is a line with english,这是一段带有英文的多行句子: this is a line with english。</p>
        </div>
    </div>
</body>