2017-04-16 3 views
-1

こんにちは、私はこの行を変更したいです $( "#Tcounter")css( "color"、 "red");このスクリプトで のカラーコード#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> 

これ以上の情報はありません!

おかげ

+0

ブラウザのコンソールにエラーがありますか? – NewToJS

+0

これを "#BC0202"と変更すると、それはまだ古い色のままです! – Rhoda

+0

私はそれを理解しています...ブラウザコンソールにエラーが表示されていますか? – NewToJS

答えて

2

シンプル、変更red

$("#Tcounter").css("color","#BC0202");
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> 
 
<div id="Tcounter">Foobar</div>

#BC0202

+0

これはコードを動作させません – Rhoda

0

ちょうど進コードの色のものの対応したを交換してください。

+0

これを行うと$ ( "#Dcounter").css( "color"、 "#BC0202");私は赤色を受け取る – Rhoda

+1

そう、この16進コードは強い赤色に属しているので、それを反映する。 –

関連する問題