window.getSelection() offset with HTML tags?
问题 If I have the following HTML: <div class="content"> Vivamus <span>luctus</span> urna sed urna ultricies ac tempor dui sagittis. </div> And I run an event on mouseup that sees the ranges of the selected text: $(".content").on("mouseup", function () { var start = window.getSelection().baseOffset; var end = window.getSelection().focusOffset; if (start < end) { var start = window.getSelection().baseOffset; var end = window.getSelection().focusOffset; } else { var start = window.getSelection()