0

I want to highlight a particular word in a textarea. I know how to do it for the entire division, but don't know how to do it for a specific word.

document.getElementById("labnol").style.backgroundColor = "lightblue";

This is what I have tried to highlight the entire div .But now want to do it for a specific word.

jgillich
  • 71,459
  • 6
  • 57
  • 85
  • 2
    Welcome to stack overflow! A quick search will point you here which provides several answers to your question. http://stackoverflow.com/questions/142527/highlight-text-inside-of-a-textarea – JamesT Apr 08 '14 at 09:28

1 Answers1

0

You have to create span element for that word with class ui-match(can be any class name)

HTML

  <p> 
       Hello <span class="ui-match">there</span>, How are you?
  </p>

CSS

 .ui-match {
     background: #FF0;
  }
Fizer Khan
  • 88,237
  • 28
  • 143
  • 153