Javascript - 更改textarea中某些文本的字体颜色 [英] Javascript - Change font color of certain text in textarea

查看:919
本文介绍了Javascript - 更改textarea中某些文本的字体颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有任何JS函数可以更改textarea中某些文本的颜色?

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

例如,blar blar {blar} blar,{blar},包括{},将是蓝色的。其他的话将是空白的。换句话说,我需要的只是一个可以改变{}中所有文本颜色的函数。

For example, blar blar {blar} blar, {blar}, including { }, will be in blue. Other words will be in blank. In other words, all I need is a function that can change color of all text in { }.

我做了一些研究,似乎大多数人都这样说无法做到。但我看到富文本编辑或那些具有粗体或下划线字母能力的编辑。必须有办法。

I've done some studies and it seems that most people say it can't be done. But I'm seeing rich text editors or those wysiwyg editors having the ability to bold or underline words. There must be a way to do it.

欢迎提出任何建议。

推荐答案

没有人提到contentEditable?

只需创建一个contentEditable div并使用javascript来设置它的风格。

我建议你看看 Dojo Toolkit's

它有一个编辑器小部件

No one mentioned contentEditable?
Just make a contentEditable div and use javascript to style it.
I reccommend you to look into the Dojo Toolkit's.
It has a Editor widget.

其他资源:

IE中的一些内容可编辑问题。

如何在jQuery或不使用的情况下使用contentEditable。

这篇关于Javascript - 更改textarea中某些文本的字体颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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