Javascript 如何更改脚本中的颜色代码

Javascript 如何更改脚本中的颜色代码,javascript,php,Javascript,Php,嗨,伙计们,我想换一条线路 $(“#t计数器”).css(“颜色”、“红色”); 在这个颜色代码为#BC0202的脚本中,我需要如何执行此操作 <script type="text/javascript"> $(document).ready(function() { var Tcharacters = <?php echo $max_character_length_title; ?>; $("#Tcounter").append("<s

嗨,伙计们,我想换一条线路 $(“#t计数器”).css(“颜色”、“红色”); 在这个颜色代码为#BC0202的脚本中,我需要如何执行此操作

<script type="text/javascript">
$(document).ready(function()  {
    var Tcharacters = <?php echo $max_character_length_title; ?>;
        $("#Tcounter").append("<small><?php osc_esc_js(_e('You have','ctg_housing')); ?> <strong>"+  Tcharacters+"</strong> <?php osc_esc_js(_e('characters remaining','ctg_housing')); ?></small>");
        $("#title<?php echo osc_current_user_locale(); ?>").keyup(function(){
    if($(this).val().length > Tcharacters){
        $(this).val($(this).val().substr(0, Tcharacters));
        }
    var Tremaining = Tcharacters -  $(this).val().length;
        $("#Tcounter").html("<small><?php osc_esc_js(_e('You have','ctg_housing')); ?> <strong>"+  Tremaining+"</strong> <?php osc_esc_js(_e('characters remaining','ctg_housing')); ?></small>");
    if(Tremaining <= 10)
    {
        $("#Tcounter").css("color","red");
        }
    else
    {
        $("#Tcounter").css("color","black");
        }
    });

    var Dcharacters = <?php echo $max_character_length_description; ?>;
        $("#Dcounter").append("<small><?php osc_esc_js(_e('You have','ctg_housing')); ?> <strong>"+  Dcharacters+"</strong> <?php osc_esc_js(_e('characters remaining','ctg_housing')); ?></small>");
        $("#description<?php echo osc_current_user_locale(); ?>").keyup(function(){
    if($(this).val().length > Dcharacters){
        $(this).val($(this).val().substr(0, Dcharacters));
    }
    var Dremaining = Dcharacters -  $(this).val().length;
        $("#Dcounter").html("<small><?php osc_esc_js(_e('You have','ctg_housing')); ?> <strong>"+  Dremaining+"</strong> <?php osc_esc_js(_e('characters remaining','ctg_housing')); ?></small>");
    if(Dremaining <= 10)
    {
        $("#Dcounter").css("color","red");
        }
    else
    {
        $("#Dcounter").css("color","black");
        }
    });
});
</script>

$(文档).ready(函数(){
变量Tcharacters=;
$(“#t计数器”)。追加(“”+Tcharacters+””;
$(“#title”).keyup(函数(){
if($(this).val().length>Tcharacters){
$(this.val($(this.val().substr(0,Tcharacters));
}
var Tremaining=Tcharacters-$(this).val().length;
$(“#Tcounter”).html(“”+Tremaining+””);

如果(训练简单,将
红色
改为
#BC0202

$(“#Tcounter”).css(“颜色”、“BC0202”);


Foobar
只需用颜色对应的十六进制代码替换颜色名称。

如果我这样做$(“#Dcounter”).css(“color”,“#BC0202”);我仍然会收到红色Yea,因为这个十六进制代码属于强红色,它会反映这一点。您的浏览器控制台中有任何错误吗?如果我用“#BC0202”更改它它仍然保持原来的颜色!我知道…您在浏览器控制台中显示了任何错误吗?没有任何错误显示我还建议您在问题上标记
jQuery
,因为此脚本正在使用jQuery插件