使用索引td查找连续td的背景颜色

时间:2018-04-19 07:57:15

标签: javascript jquery html css

我需要在当前使用Jquery附加的行中找到附加td的背景颜色,但它不起作用。

如何使用索引值获取td的css。

到目前为止,我已尝试过:

while ($(row1).children('td:nth-child(' + startIndex + ')').css('background-color') == 'rgba(0,0,0,0)') {
    startIndex = startIndex + 1;
}
//Here row1 - is tr , startIndex - Index of td which I need to find css

1 个答案:

答案 0 :(得分:0)

尝试这可能有用&满足你的要求!!

$(document).ready(function () {
    $("#table-id tr").each(function () {
        if($(this).children('td:nth-child(' + startIndex + ')').css('background-color') == "rgb(0, 0, 0)"){
          startIndex = startIndex + 1;
        }
    });
})

注意:某些浏览器支持rgba(0,0,0,0)。

相关问题