How to read/get the CSS background color of a row in a gridview

colors, css, find, jquery, rows

Solution

Use css() to get value of `background-color`

$("#gv tr:has(td)").each(function () {
     if($(this).css("background-color") == "green")
     {
     }
});

You can also use the DOM object to get color

Live Demo

$("#gv tr:has(td)").each(function () {
     if(this.style.backgroundColor == "green")
     {
     }
});

Problem

I have set the background-color of a row via CSS ``` $("#gv tr:has(td)").each(function () { $(this).css({ "background-color": "green" }); }) ``` After this , certain rows have been added How can I loop through the rows and only again find the "green" rows? ``` $("#gv tr:has(td)").each(function () { ? (if row == green){ } }) ```

Original source