无法使用JQuery设置“TD”的背景颜色

我有一张桌子

EmpIdEmpName
1ABC
2DEF

我想设置表的“td”元素的背景颜色而不是“th” 。 我试过了

 $("table").children("td").css('background-color', '#00ff00'); OR $("table").children("tr").children("td").css('background-color', '#00ff00'); 

但没有结果。

请帮忙,因为我在做什么错误?

谢谢

您可以尝试以下方式:

 $("table tr").find("td").css('background-color', '#00ff00'); 

要么

 $("table td").css('background-color', '#00ff00'); 

DEMO

根据@Matt Huggins的评论,你也可以这样做:(但不是必要的)

 $("table tbody td").css('background-color', '#00ff00'); 

DEMO