1

我想从任何可能出现的标签中删除特定的内联颜色样式。颜色的样式为 style="color: rgb(255, 102, 0);"。

我正在尝试仅使用 a 标签进行测试,但并没有走得太远。想法?不是 Jquery 人,所以我需要很多帮助:)。

    $('a[style="color: rgb(255, 102, 0)"]').remove('[style="color: rgb(255, 102, 0)"]');

    $('a[style="color: rgb(255, 102, 0)"]').remove();

    <a style="color: rgb(255, 102, 0)">not orange</a>

    <a style="color: rgb(255, 102, 0);">not orange</a>
4

1 回答 1

4

你可以使用这个:

$('a[style="color: rgb(255, 102, 0)"]').css('color', '');

但这仅在您的样式属性完全为"color: rgb(255, 102, 0)".

如果您想要更可靠的东西,例如接受其他样式属性或 CSS 规则中指定的颜色,您必须过滤:

$('a').filter(function(){
   return $(this).css('color')=='rgb(255, 102, 0)'
}).css('color', '');

示范

于 2013-04-03T18:55:30.317 回答