Is it possible to change the color of a word in a text box?

I have a regular texbox control. I need to highlight some words with red color. Is it possible to do with JavaScript (jquery or whatever)?

+1


a source to share


4 answers


Most rich text javascript editors use iframe

c designMode='on'

as it gives better cross-browser results:

<iframe ID="rtbox"></iframe>
      



To make iframe

editable and insertable rich text using Javascript, you can use the following code example:

var rtbox = document.getElementById('rtbox');
var doc = rtbox.document ? rtbox.document : rtbox.contentDocument;
doc.designMode = 'on';
doc.body.innerHTML = 'one <span style="color:red">red</span> word';

      

+5


a source


No, you cannot do this. The only way is to use an advanced text editor component like FCKEditor or similar.



0


a source


No, you cannot use different styles in the standard one <textarea>

.

0


a source


I recommend using TinyMCE for a rich text editor.

And no, what you are saying is not possible in a normal text box.

0


a source







All Articles