0
有人可以快速瀏覽一下這段代碼,讓我知道我要去哪裏錯了。幫助ajax jQuery的css的東西
在模糊事件上,.textok
類加載正常,但.textbad
類不加載。
<style>
.textok {
color:#0F0;
background-color:#093;
};
.textbad {
color:#F00;
background-color:#900;
};
</style>
<script>
$("#name").blur(function()
{
$.post("logval.php?type=name",{ name:$('#name').val() } ,function(data)
{
if(data=='noname') //if no username
{
$("#usererror").fadeTo(200,0.1,function() //start fading the messagebox
{
//add message and change the class of the box and start fading
$("#usererror").html('Name Accepted ').addClass("textbad").fadeTo(900,1);
$("#tic").attr("src","tic.gif").fadeTo(900,1);
});
} else
{
$("#usererror").fadeTo(200,0.1,function() //start fading the messagebox
{
//add message and change the class of the box and start fading
$("#usererror").html('Name Accepted ').addClass("textok").fadeTo(900,1);
$("#tic").attr("src","tic.gif").fadeTo(900,1);
});
}
});
})
</script>
偏離主題,但作爲一個良好的做法,我總是建議使用六位十六進制代碼作爲顏色參考。 – Spudley