使用javascript更改文本框文本颜色
我有一个文本框。当我单击此按钮时,我想用Javscript更改文本颜色样式。在此之前,我成功地执行了此操作。当有人单击文本框时,文本框清除内部,当模糊文本框变为旧版本时。此代码现在适用于我使用javascript更改文本框文本颜色,javascript,html,css,textbox,Javascript,Html,Css,Textbox,我有一个文本框。当我单击此按钮时,我想用Javscript更改文本颜色样式。在此之前,我成功地执行了此操作。当有人单击文本框时,文本框清除内部,当模糊文本框变为旧版本时。此代码现在适用于我 <input id="kullanici_adi_text" type="text" name="kullanici_adi_text" value="Kullanıcı İsmini Giriniz..." onfocus="if(this.value=='Kullanıcı İsmini Gi
<input id="kullanici_adi_text" type="text" name="kullanici_adi_text" value="Kullanıcı İsmini Giriniz..." onfocus="if(this.value=='Kullanıcı İsmini Giriniz...') {this.value='';} onblur="if(this.value==''){this.value='Kullanıcı İsmini Giriniz...'}"/>
这将有效
函数myFunction(){
document.getElementById(“kullanici_adi_text”).style.color=“#ff0000”;
document.getElementById(“kullanici_adi_text”).style.color=“洋红”;
document.getElementById(“kullanici_adi_text”).style.color=“blue”;
document.getElementById(“kullanici_adi_text”).style.color=“lightblue”;
}
这将有效
函数myFunction(){
document.getElementById(“kullanici_adi_text”).style.color=“#ff0000”;
document.getElementById(“kullanici_adi_text”).style.color=“洋红”;
document.getElementById(“kullanici_adi_text”).style.color=“blue”;
document.getElementById(“kullanici_adi_text”).style.color=“lightblue”;
}
1.在文档中包括jQuery库
2.包含此脚本:
$(document).ready(function(){
$('#kullanici_adi_text').focus(function(){
$(this).css('color', 'red');
}).focusout(function(){
$(this).css('color', 'black');
});
});
1.在文档中包括jQuery库
2.包含此脚本:
$(document).ready(function(){
$('#kullanici_adi_text').focus(function(){
$(this).css('color', 'red');
}).focusout(function(){
$(this).css('color', 'black');
});
});
您应该使用颜色配额:
<input id="kullanici_adi_text" type="text"
name="kullanici_adi_text"
value="Kullanıcı İsmini Giriniz..."
onfocus="if(this.value=='Kullanıcı İsmini Giriniz...')
{this.value='';
this.style.color = 'blue';}"
onblur="if(this.value=='')
{this.value='Kullanıcı İsmini Giriniz...';
this.style.color = '#ff0000';}"/>
作为建议,最好将javascript代码与标记分开。您应该使用颜色配额:
<input id="kullanici_adi_text" type="text"
name="kullanici_adi_text"
value="Kullanıcı İsmini Giriniz..."
onfocus="if(this.value=='Kullanıcı İsmini Giriniz...')
{this.value='';
this.style.color = 'blue';}"
onblur="if(this.value=='')
{this.value='Kullanıcı İsmini Giriniz...';
this.style.color = '#ff0000';}"/>
作为建议,最好将javascript代码与标记分开。您的十六进制代码颜色周围似乎缺少引号。您有:document.getElementById('kullanici_adi_text')。style.color=#fff代码>但它应该是这样的:document.getElementById('kullanici_adi_text').style.color='#fff'
@AndyHenderson无论如何都不工作您的hexcode颜色似乎缺少引号。您有:document.getElementById('kullanici_adi_text')。style.color=#fff代码>但它应该是这样的:document.getElementById('kullanici_adi_text').style.color='#fff'
@AndyHanderson无论如何都不工作我怎么能给rgba它不工作=>this.style.color='rgba(69,69,69,0.3)';请检查小提琴--这对我来说就像一个符咒。我如何给rgba它不起作用=>this.style.color='rgba(69,69,69,0.3)';请检查一下小提琴--这对我来说很有魅力。