开发者

JS/jQuery : Best way to format/emphasise specific words in a textarea

开发者 https://www.devze.com 2023-02-20 03:34 出处:网络
I want to be able to detect text that h开发者_运维知识库as been entered and display this back to the user by changing the color of specific words in a textarea. Much the same way as in Facebook or Twi

I want to be able to detect text that h开发者_运维知识库as been entered and display this back to the user by changing the color of specific words in a textarea. Much the same way as in Facebook or Twitter when a user enters a @username tag into a posting.

I want that word to be highlighted to the user before the post is submitted so that they are aware the application has acknowledged it.

What is the best way to achieve this kind of styling?


Textarea elements do not allow styling:

<textarea><b>Hi</b></textarea>

Will not bold the text, it will display the html as text. Instead, try the contenteditable attribute.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号