1

Highlight text color not background color in text area area by using jquery . I dont want background color as highlighted , The letter should get highlighted

Krish R
  • 22,583
  • 7
  • 50
  • 59
  • 1
    set color like `$('textarea').css('color', 'red')` – Arun P Johny Dec 28 '13 at 15:51
  • If it is about the user selection and not the whole text, then this is probably helpful: [CSS3 - How to style the selected text in textareas and inputs in Chrome?](http://stackoverflow.com/questions/8438418/css3-how-to-style-the-selected-text-in-textareas-and-inputs-in-chrome) – t.niese Dec 28 '13 at 15:56

3 Answers3

1

You can set the color of the textarea using .css('color', color) like

$('textarea').css('color', 'red')

Demo: Fiddle

Arun P Johny
  • 384,651
  • 66
  • 527
  • 531
0

Try this,

CSS:

.Highlighter{     
    color: red;
 }

Jquery:

$('textarea').addClass('Highlighter');
Krish R
  • 22,583
  • 7
  • 50
  • 59
0

What i understood is you want to color the the text which is selected by user. I don't think thats possible that way in an input element. I suggest you to use ::selector{} css3 selector with a contenteditable(html5 editable div attribute) div which can be used like text area and you can achieve what you need this way:

::selection{
    color: #ff0000;
}

and your div:

 <div contenteditable='true'>
      This is the dummy content.
 </div>

and here you can play with fiddle.

Jai
  • 74,255
  • 12
  • 74
  • 103