3

Possible Duplicate:
Change the Color Of Certain Words In Textarea using Jquery?

I'm working on a small project right now. I have a textarea that the user types words into. While the user is typing, I need the text to change color if they use certain words. For example, as lucy is typing the sentence "The brown cow jumped over the moon" the text would make the word "brown" a brown color, but live right after she types the space after "brown". I hope you understand :P Oh and jquery is an option.

Community
  • 1
  • 1
Kyle Morgan
  • 660
  • 1
  • 11
  • 21

2 Answers2

0

This isn't possible with current technology using a textarea. You can change the color of everything in the textarea, but textareas do not have the capability to selectively style some words but not others.

Peter Olson
  • 139,199
  • 49
  • 202
  • 242
0

As has been said before, it's not possible to achieve the required level of control over presentation in a regular textarea.

Here are a couple of stackoverflow questions on the issue:

You could look at using something like codepress and editing the source code to highlight the words you want.

Or if you wanted to do it from scratch you could use <div contentEditable="true"></div> instead of a textarea as suggested here:
colorize text in textarea with jQuery

Here is some example code without the jquery span replacement:
http://jsfiddle.net/s5uaJ/

Good luck

Community
  • 1
  • 1
3dgoo
  • 15,716
  • 6
  • 46
  • 58