I use this code How can I position an element next to user text selection? to get the position of the selected text, but it doesn\'t work for the selected text inside an input.
You can use the following code to get the position of selected text:
var selection = window.getSelection(); var getRange = selection.getRangeAt(0); getRect = getRange.getBoundingClientRect();