开发者

Is there a way to select one whole column in a table to style differently?

开发者 https://www.devze.com 2022-12-18 05:07 出处:网络
Is there a way to select one whole column in a table to style differently? without adding class or id to all those td?

Is there a way to select one whole column in a table to style differently? without adding class or id to all those td?

I want to do with HT开发者_Python百科ML and css 2.1 only. with cross browser compatibility


You could try to use <col> element.


You can select a column in a table by using jQuery cell selector plugin. Here is the example:

$('#mytable tbody td:nth-col(4)');

This code shows how to select the fourth column of a table.

HTH


I think recent versions of Safari, Opera and Firefox support the :nth-child CSS selector, so that’s another option.

I don’t think IE 6 and 7 will give you any joy though, you’re stuck with adding classes to the <td>s there.

0

精彩评论

暂无评论...
验证码 换一张
取 消