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");

したがって、実際には無効な属性は削除されますが、色の属性は削除されません

4

5 に答える 5

2

属性名を渡す必要removeAttr() がありますが、正しい構文ではない値で名前を渡しています。removeAttr() ここの構文を確認してください。css()を使用して色属性を設定できます。

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

removeAttr を使用して要素を有効にする代わりに、 use .attr('disabled', false); を使用することもできます。

于 2013-04-10T07:23:36.627 に答える
2

.css() - 一致した要素のセットの最初の要素のスタイル プロパティの値を取得するか、一致した要素ごとに 1 つ以上の 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");
于 2013-04-10T07:24:22.210 に答える
2

jquery Api のドキュメントに記載されているように、removeAttr - 関数は 1 つの条件のみを受け入れます。だからあなたが何かをするなら

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

これは、要素のスタイルを削除することを意味し、「#999999」は破棄されます。無効な部分についても同様です。

お役に立てば幸いです。

敬具、アレックス

于 2013-04-10T07:27:30.200 に答える