1
<div contenteditable="true">This text is <b>Bold</b> not <i>Italic</i> right?</div>

For example if

text is Bold not

is selected by the user, how do i know the exact position(offset) of the selection (highlight). I have read several articles about this but could not find one that explain. Thanks

1 Answers1

0

The best possible solution is probably to surround the selected text with an element and then get that elements position, see: How can I position an element next to user text selection?

Community
  • 1
  • 1
Callan Heard
  • 727
  • 1
  • 8
  • 18
  • Thanks. But I would have preferred to get the exact positions as stated above because of the logic I want to apply it with. Am working on a compose area of a site where user/client will simply click on the 'B' to get bold, 'I' for italic blah blah... just like in your ms-word application –  Sep 09 '15 at 10:40
  • So add the element (for example `` ) with a reference counter or something and then apply the styles to it that the user clicks? – Callan Heard Sep 09 '15 at 10:42