user142528
user142528

Reputation:

Jquery: set style part of text in input text

I want to create some text based on user input, and when user enter some text, the first word will automatically set backgroundcolor, but the other words still remain same (no background color), can I do this ?

Thanks

Upvotes: 0

Views: 2907

Answers (2)

rahul
rahul

Reputation: 187030

WYSIWYG editor will be the best choice for previewing text and editing at the same time.

Some popular ones are

  1. TinyMCE
  2. STEditor
  3. FCKeditor

Upvotes: 1

Kane Wallmann
Kane Wallmann

Reputation: 2322

You could do it with an iFrame if you turn designMode on, add an event listener for keypress then wrap the first word in the iFrames body with <span style='background-color: red'></span>. You would then have to have a hidden form field that mirrored the data that is typed into the iFrame (removing the span tag).

If you want to go this way let me know if you need any more help.

Upvotes: 0

Related Questions