<div contenteditable="true">This text is <b>Bold</b> not <i>Italic</i> right?</div>
例如,如果
text is Bold not
由用户选择,我如何知道选择(突出显示)的确切位置(偏移)。我读过几篇有关此的文章,但找不到一篇对此进行解释的文章。 谢谢
最佳答案
最好的解决方案可能是用一个元素包围所选文本,然后获取该元素的位置,请参阅:How can I position an element next to user text selection?
关于javascript - contenteditable div 中突出显示的文本 : Get the start and the end of the highlighted text,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32476650/