Search This Blog

Monday, June 21, 2010

javascript string clicked position

Programmer Question

Hello all,
If I have a string in a div




lots of text goes here
it's really interesting
and it's free to read


if a user double click or single click on a particular word, is there a way to determine the position/index of the character clicked?



If that cannot be done, how about determining how many space character there are before the clicked position. So if I click on the word 'goes' in the above example, it returns 3 because there are three spaces before the word goes which is clicked.



Thank You very much for your time.



Find the answer here

No comments:

Post a Comment

Related Posts with Thumbnails