Select elements which have color:lightGreen in CSS using jQuery

css, html, javascript, jquery

Solution

$("a").each(function() {
    if ($(this).css("color") == "rgb(144, 238, 144)") {
        $(this).css("color", "#666");
    }
});

Or if you prefer using `filter`:

$("a").filter(function() {return $(this).css('color') == 'rgb(144, 238, 144)';})
.css("color", "#666");

BUT if you had the opportunity to edit the markup, you're best off adding the light green colour to a class, then applying the class to those elements, then you can have another class for your new colour, then change them like so:

$(".lightGreen").removeClass("lightGreen").addClass("newColour");

Problem

How do I select elements which have property `color:lightGreen` in CSS using jQuery and then change it to `#666`? Example Html: ``` <a id="ctl00_ContentPlaceHolder1_GridView1_ctl17___ID_DetailsHyperLink" class="CorporateHyperlink" href="/EstimateSite/Estimate/Details.aspx?ID=234" style="color:LightGreen;">Details</a> ```

Original source