0

Is there any way via JS to highlight text inside a textarea that matches a specific pattern?

I am loathe to use a fully WYSIWYG editor as I just want to highlight certain text (references in scientific writeups, they become very cumbersome to read over).

Sol Orwell
  • 115
  • 1
  • 3
  • 9
  • Don't think one can do that, can't have html inside a textarea. The best way is probably to replace the textarea with an `iframe` which can have html in it. I suppose you'll have to use JS to catch the key presses and enter the content as well though. – ianbarker Apr 25 '12 at 16:19
  • the question was solved in another post: [Solved here][1] [1]: http://stackoverflow.com/questions/142527/highlight-text-inside-of-a-textarea – Fred Qin Jul 20 '15 at 19:05

2 Answers2

1

textarea can not support different colors. So your answer is you can not do it in a textarea.

epascarello
  • 204,599
  • 20
  • 195
  • 236
1

Take a look at this article: Javascript - Change font color of certain text in textarea

Summarized, you cannot add tags inside of a textarea, so you cannot modify the font/style of text contained within it.

Community
  • 1
  • 1
gcochard
  • 11,408
  • 1
  • 26
  • 41