Writing a string to textarea without markup in JS

Hi

I am trying to selectively colour text, according to word length. I have achieved a string with markup included, e.g. < font color=“green”>< font>

My problem is how do I write this, programmatically, to a text area (already included in a form div) as a normal string, appropriately coloured, without the markup? I can do that with document.write()… but that is not very elegant, and also loses paragraph divisions.
Any help or advice is welcome. Tony.

Tony, do you absolutely have to have the text inside a textarea? AFAIK, you can’t change the color of individual segments inside a textarea element. The way you see many popular text editors accomplish something similar is by using span elements inside a div.

Thanks Kirupa, no but that seemed the way to do it. I wrote a program in Python to do this, which modifies the text in place within a Tkinter text box. In trying to replicate that in JS, I extracted the contents which the user pastes into a text area, then manipulated it using changecolour(). But I don’t know where to put the resulting changed string, text area doesn’t accept it.

I will research the span/div approach, but as a relative newcomer to JS it would help if you could point me to an example, i.e. modifying the colour of user-input text within strings, and showing this again with only the colour changed.

Many thanks for your help

Tony