开发者社区> 问答> 正文

table找出同一列相同内容,并设置相同的背景

screenshot
现在可以找到相同的行数,但是颜色弄不一致,代码如下:
希望做到相同的文字颜色也一样。

 for(var n=0;n<rows;n++)
{   
    temp=$("#exampletable tr:eq("+n+") td:eq(1)").html();
    var bgcolor=getRandomColor();
     if(temp==$("#exampletable tr:eq("+(n+1)+") td:eq(1)").html()){

    $("#exampletable tr:eq("+n+") td:eq(1)").css('background-color',bgcolor);
    $("#exampletable tr:eq("+(n+1)+") td:eq(1)").css('background-color',bgcolor);
    } 

} 

展开
收起
小旋风柴进 2016-03-18 13:29:51 1943 0
1 条回答
写回答
取消 提交回答
  •  for(var n=1;n<=rows;n++)
    {   
        temp=$("#exampletable tr:eq("+n+") td:eq(1)").html();
        var sha=$.md5(temp.toString());
        var bgcolor=sha.substring(sha.length-6);
        $("#exampletable tr:eq("+n+") td:eq(1)").css('background-color',"#"+bgcolor);
        }
    2019-07-17 19:06:26
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载