Garry
Garry

Reputation: 306

Select box styling issue

i have this select box :

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

and i am using :

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

so it actually removes disabled attribute but not the color attribute

Upvotes: 2

Views: 137

Answers (5)

Adil
Adil

Reputation: 148178

You have to pass attribute name to removeAttr() but you are passing name with value which is not correct syntax, check syntax of removeAttr() here. You can use css() to set the color attribute.

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

Instead of using removeAttr to enable the element you can also use use .attr('disabled', false);

Upvotes: 2

Amit
Amit

Reputation: 15387

Use this:

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

Upvotes: 2

ssilas777
ssilas777

Reputation: 9764

Don't mix attributes with Styling.

In Jquery you should use .css() property to work with styling, So this should work

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

Upvotes: 2

Ilinea
Ilinea

Reputation: 62

As stated in the jquery Api documentations, the removeAttr - function only accepts 1 condition. so if you do something like

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

it means that you remove the style on the element, and the '#999999' is discarded. Same goes for the disabled part.

I hope it helps.

Kind regards, Alex

Upvotes: 2

Pranay Rana
Pranay Rana

Reputation: 176956

.css() - Get the value of a style property for the first element in the set of matched elements or set one or more CSS properties for every matched element.

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

or

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

Upvotes: 2

Related Questions