Is it possible to work out where in a p's text a mouse click event occurred?
I have a <p> containing text. When the <p> is clicked on, I create a <textarea> containing the text from the <p> . Is it possible to calculate where in the <p> 's text the click occurred, and move the <textarea> 's cursor to that same point? I don't believe so, no. The DOM just knows what containing element received the click event, it doesn't distinguish between pieces of text within the containing element unless they are elements themselves. And I doubt you want to wrap every character in your text with its own element tag :) Hope this simple example helps: <html> <head/> <body> <script type