2013-05-12 59 views
0

我的CSS提交按钮(简称为便于阅读):添加类不改变风格

input[type="submit"] 
{ 
background-color:#3bb3e0; 
padding:10px; 
position:relative; 
font-family: Arial, sans-serif; 
font-size:12px; 
text-decoration:none; 
color:#fff; 
border: solid 1px #186f8f; 
border-radius: 5px; 
cursor:pointer; 
} 

当用户如果填写表格,而错误使用AJAX我想禁用检查提交按钮,如果用户输入一些错误改变其颜色,所以我用下面的jQuery:

if(response == 0) 
{ 
$("#button").addClass("buttonDisable"); 
$('#cross').fadeIn(); 
$('#button').prop('disabled', true); 
} 

按钮禁用确定,但CSS没有效果的检查显示它最初的CSS后添加,因此它被划掉:

input[type="submit"].buttonDisable { background-color:#ccc; border:1px solid #666; } 

问题:我该如何让班级对按钮有影响?

+9

这将是对'fashion.stackexchange.com'这样一个热闹的问题的标题如果它存在:) – 2013-05-12 07:51:25

+0

@Pekka웃哈哈辉煌!谢谢你的微笑 – 2013-05-12 07:56:09

+0

似乎工作给我.. http://jsfiddle.net/23UAs/ – 2013-05-12 07:57:53

回答

2

试试这个: -

input[type="submit"][disabled] { background-color:#ccc; border:1px solid #666; }