Javascript - Change font color of certain text in textarea

后端 未结 5 2064
忘掉有多难
忘掉有多难 2020-12-31 23:33

Is there any JS function that can change the color of certain text in a textarea?

For example, blar blar {blar} blar, {blar}, including { }, will be in blue. Other w

5条回答
  •  再見小時候
    2021-01-01 00:22

    wysiwig-editors are using iframes instead of textareas. Textareas are very little customizable, since what you're after is changing part of the content. You can't add tags inside a textarea, which makes it impossible to only change part of the text.

    If you look at the editor here in SO, you write normal text inside a textarea, and it is then transformed in the box below it, so you'll see the asterix inside the textbox, but in the box below, it'll transform special characters by regexing them with tags.

    If you're using firebug, you can start writing inside the editor, while looking at the HTML in the preview-box.

提交回复
热议问题