How does JavaScript get the offset of a selection?

The

scene appears in a rich text editor. I want to select a piece of text, and then a tooltips appears above the selected text

.

it is not clear which method should be used to get the start and end points of a selection (selection) relative to the offset of the body (not the character offset) to locate the tooltips element.

Mar.24,2021

  

$(selector). Offset ()

Menu