I create a suggestion panel when editing an HTML text box. To get the coordinates {x, y}, I use a hidden div located behind the text box. I get the carret position and then copy the text in front of the carret plus the span label to the hidden div. Then I get the coordinates of the range and pass it to the suggestion bar.
The only problem is that when I add a long line without spaces in the text box, the line is wrapped when it is cut in the div panel (so the suggestion panel no longer fits until I add a carriage return).
Is there a way to place text in the same way in these two places (textarea panel and div)?
(I am using jQuery)
source share