find text position in an element
The following is for a complicated application I'm writing. I don't expect the first question can be answered, but why not try:
1) Suppose I have an element such as ARTICLE with an id such as "myArticle". If the user clicks his mouse inside that element, I can find the position of the mouse (using .offset or something like that), but is there a way to find the text offset? I don't see how there could be, unless the text letters were all the same width, (as in Courier font) and only if I knew there were no intervening images or paragraphs etc. But I want to standardize it to the extent that if different users click on the letter A in APPLE, that even though their cursor position may vary by a few pixels when they click, I can return a standard number for the position.
2)
Also, I saw a JavaScript construct that I don't understand:
CurrentSelection.Selector.getSelected = function()
and
CurrentSelection.Selector.mouseup = function()
It seems that these routines can get the exact text that is highlighted in a div, and then modify it. Is there anything like that in jQuery? Suppose user moves his mouse over a word, and I want the word to change into an image of Count Dracula. (I don't, but that's an example). I know jQuery has $(#ELEMENT).HTML() which could do that, but that usually depends on having an element. I'm seeing JavaScript where you don't need to replace the entire element, just a part of it. (The javascript code that I saw was at:
http://jsfiddle.net/dipaks2011/uz0gsu8a/1/ )
Thanks.