更改textarea中特定零件的文本颜色 [英] Change textcolor of specific parts in textarea

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

问题描述

有可能改变HTML中textarea中某些部分的文本颜色吗?

Is there any possibility to change the text-color of some parts in a textarea in HTML?

我喜欢在我的网站上输出一些高亮的PHP代码,给予通过一次点击这个textarea选择完整的代码的可能性。
我已经写了一个javascript函数来选择完整的文本。但是如果我尝试把文本放在文本周围,也会打印出来。

I like to output some highlighted PHP-Code on my website and give the possibility to select the complete code by one click on this textarea. I've already wrote a javascript function to select the complete text. But if I try to put spans around the text, they are printed, too.

也许应该使用div,如果有办法选择文本

Maybe it should work with a div, if there is a way to select the text in a div by one click.

推荐答案

不,这是不可能的,但你可以有一些css使一个div看起来像一个< textarea> ,在div里面你可以把几个< span>

No, it's impossible, but you can have some css to make a div to look like it's a <textarea> and inside the div you can put several <span>s with colors.

您也可以使用这样的< a>

You can also use something like this

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

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