2016-03-23 22 views
0

kodum:CCS değişikliği ön renk onfocus/Onblur

<asp:TextBox ID="TOTAL" 
onfocus="if (this.value == this.defaultValue) { this.value = ''; this.ForeColor = black; }" 
onblur="if (this.value == '') this.value = this.defaultValue; this.css('color', 'LightGray');" 
style="text-align: center;" runat="server" Height="16px" Width="60px" ForeColor="LightGray">8</asp:TextBox> 

deniyorum:

this.css('color', 'LightGray') 

veya

this.ForeColor = black 

veya

this.ForeColor = 'black' 

çalışmıyor, ben yok kullanımı gibi JQ istiyor:

$('input').focus(function(){ 
if($(this).val() == this.defaultValue){$(this).val('');$(this).css("color","green");} 
}).blur(function(){ 
if($(this).val() == ''){$(this).val(this.defaultValue);$(this).css("color","grey");} 
}); 

cevap

0
.classname{color:grey} 
.classname:focus, .clasname:active { color:green} 
0

this.style.color kullanmayı deneyin. o sizin için genel çözer ne jQuery olan çapraz tarayıcı/çapraz (eski) -version, çalışacaktır ancak anlaşılan o karşı

emin değil ...

0

@Peter B teşekkür eder çalışma;)

ÇÖZÜM:

<asp:TextBox ID="TOTAL" onfocus="if (this.value == this.defaultValue) { this.value = ''; this.style.color = 'black'; }" 
     onblur="if (this.value == '' || this.value == this.defaultValue) { this.value = this.defaultValue; this.style.color = 'LightGray'; }" style="text-align: center;" runat="server" Height="16px" Width="60px" ForeColor="LightGray">8</asp:TextBox>