Select first TD in every row w/ jQuery

前端 未结 5 2074
轮回少年
轮回少年 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:26

    you were pretty close, i think all you need is :first-child instead of :first, so something like this:

    $("#myTable tr td:first-child").addClass("black");
    

提交回复
热议问题