2013-04-10 66 views
2

我有这个选择框:选择框造型问题

<select class="slctbx condition-Combiner" onchange="updateConditionBuilder()" style="color: rgb(153, 153, 153);" disabled="disabled">

,我使用:

$('#rule-condition-listing tr:last-child .condition-Combiner').removeAttr("style","#999999").removeAttr("disabled","disabled");

因此它实际上消除禁用属性,但不是颜色属性

回答

2

.css() - 获取匹配元素集合中第一个元素的style属性的值,或为每个匹配元素设置一个或多个CSS属性。

$('#rule-condition-listing tr:last-child .condition-Combiner'). 
    css("color","#999999"). 
    removeAttr("disabled","disabled"); 

$('#rule-condition-listing tr:last-child .condition-Combiner'). 
    css("color",""). 
    removeAttr("disabled","disabled"); 
2

您必须将属性名称传递给removeAttr()但是您正在传递的名称的值是不正确的语法,检查语法removeAttr()here。您可以使用css()来设置颜色属性。

$('#rule-condition-listing tr:last-child .condition-Combiner').css("color","").removeAttr("disabled","disabled"); 

而不是使用removeAttr,让你也可以使用使用.attr(“禁用”,假)的元素;

2

如jquery的阿比单证所述,removeAttr - 功能只接受1分的条件。所以如果你做的事情如

$('#rule-condition-listing tr:last-child .condition-Combiner').removeAttr("style","#999999").removeAttr("disabled","disabled"); 

这意味着你删除元素的样式,'#999999'被丢弃。残疾人部分也一样。

我希望它有帮助。

亲切的问候,亚历克斯

2

不要混合属性与造型。

在jQuery的你应该使用.css()属性与造型工作,所以这应该工作

$('#rule-condition-listing tr:last-child .condition-Combiner').css("style","").removeAttr("disabled","disabled"); 
2

使用此:

$('#rule-condition-listing tr:last-child .condition-Combiner').css("color","").removeAttr("disabled","disabled");