如何获取colspan / rowspan表头中的列数

时间:2012-01-06 20:16:20

标签: jquery html html-table

我有一个包含两行和几行行的表头“和一个colspans单元格,如下所示:

<table>
  <thead>
    <tr>
      <th rowspan="2">Company</th>
      <th rowspan="2">Last Trade</th>
      <th rowspan="2">Trade Time</th>
      <th rowspan="2">Change</th>
      <th rowspan="2">Prev Close</th>
      <th rowspan="2">Open</th>
      <th colspan="3">Stuff</th>
    </tr>
    <tr>
      <th>Bid</th>
      <th>Ask</th>
      <th>1y Target Est</th>
   </tr>
 </thead>

这个表因此有9列,但它可以是任何随机数。我需要根据表头中的单元格遍历所有列,因此我可以将标题列ID作为属性分配给下面的所有单元格。

是否有一般方法可以获取包含每列相应单元格的jquery选项?

1 个答案:

答案 0 :(得分:0)

简而言之:

$("tr").find("td").each(function() {
    // Manipulate results.
});