2011-08-09 47 views
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> 
+0

偏離主題,但作爲一個良好的做法,我總是建議使用六位十六進制代碼作爲顏色參考。 – Spudley

回答

6

你不把分號在CSS中右括號後:

.textok { 
    color:#0F0; 
    background-color:#093; 
} /* No semicolon here! */ 

這是那些阻止你的CSS從理解分號。