I have a function that returns an array with two elements, however it won't work in IE.
- The function returns the HTML code of what the user selects inside a div (with id=text).
- It also returns the range of the selection.
If the user selects a simple string inside the text div, the range will return correct values. However, if the user selects a string inside a child element of the div (such as div#text->p), the range's values are related to the child element instead of the parent (div#text).
You can test this on JsFiddle here: http://jsfiddle.net/paglia_s/XKjr5/. If you select a combination of normal text or bolded text in the textarea, you'll get the right selection. But if you select only the bolded word ("am"), you'll get the wrong one because the range is related to the child element.
Is there a way to make sure the range is always related to div#text?