将CSS样式应用于表的每个TD元素 [英] To apply a CSS style to every TD element of table
本文介绍了将CSS样式应用于表的每个TD元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将样式应用于具有ID DataContainer的表,如下所示:
I am trying to apply a style to a table with ID DataContainer like this:
$("#DataContainer td").addClass("width200");
$("#DataContainer th").addClass("width200");
但是它将类应用于表头中的TH元素,而不应用于TBODY部分下的常规TD中.
however it applies class to TH elements in table head but not in the regular TDs under TBODY section.
您能建议我为此选择合适的人吗?
Could you please suggest me a right selector for that?
推荐答案
$('#DataContainer').find('td').addClass("width200");
应选择DataContainer的所有td子代.有关更多详细信息,请参见 jQuery .find
should select all td children of DataContainer. see jQuery .find for more details
这篇关于将CSS样式应用于表的每个TD元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文