Does anyone know how I could change the color of a specific word if it is typed into a textarea? For instance, if the user types 'hello my friend', it would dynamically change 'hello' to green? Spent a large amount of time on google, and could not find anything very related.开发者_开发问答 Thank you.
textarea
s aren't designed to be selectively colored.
You can't do it in a textarea field because its only content can be text, not HTML. You'll have to use an editable DIV or something, and then replace the word in string with <span>word</span>
and apply a CSS class to the SPAN.
In textarea you can't. But there is posibility of "editable div". See http://codemirror.net/
The HTML specs don't allow different fonts within the same textarea element. You can't do this.
However, you can make an editor with JS that will do pretty much what you want. These things tend to be pretty big projects, so you probably want something premade. There is a list here.
精彩评论