Reputation: 149
I am trying to display XML data in a textarea and trying to make onClick event on content of textarea. For eg.
< textarea >Hello Web, This is simple html page.< / textarea >
Here I want to make onClick event on each 'i' character.
Please help me on this.
Upvotes: 0
Views: 293
Reputation: 1524
Well, you can't however you can use a little workaround. Add onclik event, and check caret position in the textarea, then you know between what characters it's located.
How to get it described here:
Caret position in textarea, in characters from the start
textarea.onmouseup = textarea.onkeyup = function () {
console.log(getCaret(textarea));
};
it returns and index for textarea value string...
here is fiddle for you:
http://jsfiddle.net/acrashik/ydLKF/1/
Upvotes: 1