【发布时间】:2018-03-15 22:36:55
【问题描述】:
大家好,我尝试从颜色词$("#Tcounter").css("color","black") 输入颜色代码;在这个脚本中从"black" 到"#317D29"。我怎样才能做到这一点?
<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");
}
});
</script>
谢谢
【问题讨论】:
-
还有……有什么问题?只需输入
#317D29而不是black。 -
@Ansel Mae 为什么
$("#Tcounter").css("color","#317D29")不起作用? -
不,那是行不通的
-
但是当它只是黑色时它可以工作?
-
您上面的脚本甚至无效
标签: javascript jquery css