我怎样才能改变textarea的文本颜色动态? [英] How can I change textArea text color dynamically?

查看:495
本文介绍了我怎样才能改变textarea的文本颜色动态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建的SQL查询editor.My想法是有一个的textarea 在用户插入查询像 SELECT * FROM TBL 然后我从 textarea的文字,然后放在的SqlCommand 和GridView控件执行查询并显示结果。但问题是,我如何改变关键字颜色就像当用户则自动改变颜色<输入插入 SELECT 命令code>蓝色就像在SQL查询编辑器和所有其他关键字,比如 SELECT 插入更新删除,所以我on.How可以更改颜色textarea的运行。

I'm creating SQL query editor.My idea is there is a textarea in which user insert query like select * from tbl and then I get text from textarea and then put in sqlcommand and execute query and show result in gridview.But Problem is how can I change keyword color like when user enter INSERT or SELECT command then automatically it change color blue like in SQL query editor and all other keywords like SELECT, INSERT, UPDATE, DELETE and so on.How can I change color runtime in textarea.

推荐答案

您可以使用CSS试试。
注 - 更改颜色的选择(这是红色):

You can try it using css . Note-Change color to any choice(this one is red):

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style type="text/css">
    input, select, textarea{
    color: #ff0000;
}

textarea:focus, input:focus {
    color: #ff0000;
}
</style>
</head>
<body>
    <form id="form1" runat="server">

        <textarea id="textarea" cols="20" name="S1" rows="2"></textarea></p>
</body>
</html>



更新

我想试试,但你能得到这个已经完成:

I thought to try but you can get this is already done :

http://stackoverflow.com/questions/37139076/change-color-of-specific-words-in-textarea

这篇关于我怎样才能改变textarea的文本颜色动态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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