Getting selected text position

后端 未结 3 613
伪装坚强ぢ
伪装坚强ぢ 2020-11-29 21:47

Currently I\'m getting the selected text in the browser doing this:

window.getSelection();

Now I need to show a tooltip above that text whe

3条回答
  •  南笙
    南笙 (楼主)
    2020-11-29 22:12

    The easiest way is to insert a temporary marker element at the start or end of the selection and get its position. I've demonstrated how to do this before on Stack Overflow: How can I position an element next to user text selection?

提交回复
热议问题