Select first TD in every row w/ jQuery

前端 未结 5 2083
轮回少年
轮回少年 2020-12-23 19:10

How do I assign a style to every first cell of every row in a table?

$(\"#myTable tr td:first\").addClass(\"black\");
5条回答
  •  孤城傲影
    2020-12-23 19:35

    like this:

    $("#myTable tr").each(function(){
        $(this).find('td:eq(0)').addClass("black");
    });
    

提交回复
热议问题