I am trying to find the textual start and end of the selection. So, in the following text, if I selected \"world! What a fine\" from within \"Hello, world! What a fine day
This is possible but slightly complicated with contenteditable HTML content (as opposed to text within an or element). Here's a simple cross-browser implementation: