使用Jquery在Textarea中更改某些词的颜色? [英] Change the Color Of Certain Words In Textarea using Jquery?

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

问题描述

如何使用Jquery在Textarea中改变某些字的颜色?



例如,我有一个textarea < textarea id = txt> < / textarea>



当我输入textarea时,像is,a,was ...或突出显示。



目的是为我的项目创建一个超简单的HTML语法高亮笔。



您需要使用内容可编辑的< iframe>



这是不可能的原因是< TEXTAREA> 在任何浏览器,支持格式化。您需要一个不同种类的元素,以便单词可以包装在元素中,格式化文本。


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

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

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

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

解决方案

This is completely impossible.

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中更改某些词的颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆