How do I have different font colors in a textarea?

后端 未结 3 1332
醉酒成梦
醉酒成梦 2021-02-09 10:29

I want the font color to change in a textarea as I type in specific keywords, like in Visual Studio.

I have not seen this anywhere, so I don\'t know if this is possible

3条回答
  •  忘了有多久
    2021-02-09 11:19

    You would probably have to run javascript on the client to detect when the text changes, then replace the text to be highlighted with some child html elements with the proper style.

    For example

    Original text:

    This is what the user typed.
    

    Highlighted text

    This is what the user typed.
    

提交回复
热议问题