Select elements with color: lightGreen in CSS using jQuery

How to select elements with color:lightGreen in CSS using jQuery and then change it to #666 ?

Html example:

 <a id="ctl00_ContentPlaceHolder1_GridView1_ctl17___ID_DetailsHyperLink" class="CorporateHyperlink" href="/EstimateSite/Estimate/Details.aspx?ID=234" style="color:LightGreen;">Details</a> 
+2
javascript jquery html css
May 18 '12 at 11:08
source share
3 answers
 $("a").each(function() { if ($(this).css("color") == "rgb(144, 238, 144)") { $(this).css("color", "#666"); } }); 

Or, if you prefer to use 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, it is best to add a light green color to the class, and then apply the class to these elements, then you can have a different class for your new color, and then change them like this:

 $(".lightGreen").removeClass("lightGreen").addClass("newColour"); 
+5
May 18 '12 at 11:11
source share

Try the following:

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

http://jsfiddle.net/z8Q5K/2/

It works great ...

+2
May 18 '12 at 11:18
source share
 $("a").each(function() { if ($(this).css("color") == "rgb(144, 238, 144)") { $(this).css("color", "#666"); } }); 
+1
May 18 '12 at 11:19
source share



All Articles