0

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.

Manish
  • 139
  • 1
  • 3
  • 17

1 Answers1

1

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/

Community
  • 1
  • 1
Sergei Zahharenko
  • 1,514
  • 12
  • 16