本文介绍了使用Jquery更改Textarea中某些单词的颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用Jquery改变Textarea中某些单词的颜色?

How to Change the Color Of Certain Words In Textarea using Jquery ?

例如,我有一个 textarea </textarea>

For instance, i have a textarea <textarea id="txt"> </textarea>

当我在 textarea 中输入时,某些单词如is, a , was ..."应该被着色或突出显示.

When i type into the textarea, certain words like "is, a , was ..." should be colored or highlighted.

目的是为我的项目创建一个超简单的 HTML 语法荧光笔!

The aim is to create a ultra simple HTML syntax highlighter for my project that's all !

推荐答案

这完全不可能.

您需要使用内容可编辑的.

You need to use a content-editable <iframe>.

不可能的原因是 在任何浏览器中都无法支持格式化.您需要一种不同类型的元素,以便文字可以包含在元素中,从而格式化文本.

The reason it's not possible is that the <TEXTAREA> has no ability, in any browser, to support formatting. You need a differnt kind of element, so that words can be wrapped in elements, formatting the text.

这篇关于使用Jquery更改Textarea中某些单词的颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 15:33
查看更多