2009-02-25 69 views
2

我用thead(表头)做了一个表格;在Mac上,在Firefox中一切都很好,但在Internet Explorer 6上,头部刚刚消失...为什么我的网站没有出现在Internet Explorer中?

任何想法为什么?

下面是测试它的链接:...该表中tablerize.js构建http://www.acecrodeo.com/new/05-rodeos.php:页面上

jQuery.fn.tablerize = function() { 
    return this.each(function() { 
     var table; 
     $(this).find('li').each(function(i) { 
      var values = $(this).html().split('*'); 
      if(i == 0) { 
       table = $('<table>'); 
       var thead = $('<thead>'); 
       $.each(values, function(y) { 
        thead.append($('<th>').html(values[y])); 
       }); 
       table.append(thead); 
      } else { 
       var tr = $('<tr>'); 
       $.each(values, function(y) { 
        tr.append($('<td>').html(values[y])); 
       }); 
       table.append(tr); 
      } 
     }); 
     $(this).after(table).remove(); 
    }); 
}; 

...从列表:

<ul> 

<li>&nbsp; Date*Endroit*Sanction</li> 
<li>&nbsp; 29 Mars &amp; 5 Avril*St-&Eacute;variste, Beauce&nbsp; # 1*&Eacute;quipe Rod&eacute;o du Qc.</li> 
<li>&nbsp; 12 &amp; 19 Avril*St-&Eacute;variste, Beauce&nbsp; # 2*&Eacute;quipe Rod&eacute;o du Qc.</li> 
<!-- ... --> 
</ul> 
+0

我在代码中找不到任何THEAD ... – Guffa 2009-02-25 17:57:02

+0

该表由JS根据列表构建。 – Shog9 2009-02-25 17:59:34

回答

5

因为我是tablerize的作者,所以我可能会修复它。

jQuery.fn.tablerize = function() { 
    return this.each(function() { 
     var table = $('<table>'); 
     var tbody = $('<tbody>'); 
     $(this).find('li').each(function(i) { 
      var values = $(this).html().split('*'); 
      if(i == 0) { 
       var thead = $('<thead>'); 
       var tr = $('<tr>'); 
       $.each(values, function(y) { 
        tr.append($('<th>').html(values[y])); 
       }); 
       table.append(thead.append(tr)); 
      } else { 
       var tr = $('<tr>'); 
       $.each(values, function(y) { 
        tr.append($('<td>').html(values[y])); 
       }); 
       tbody.append(tr); 
      } 
     }); 
     $(this).after(table.append(tbody)).remove(); 
    }); 
}; 

这应该做到这一点。

6

你包括<th>元素直接在<thead>组中;这实际上并不合法。你必须将它们括在一个<tr>元素,并把<thead> ...

参见:11.2.3 Row groups: the THEAD, TFOOT, and TBODY elements

所以修改jQuery.fn.tablerize()追加<th>元素之前插入<thead><tr>

table = $('<table>'); 
var thead = $('<thead>'); 
var headRow = $('<tr>'); 
$.each(values, function(y) { 
     headRow.append($('<th>').html(values[y])); 
    }); 
thead.append(headRow); 
table.append(thead); 

请注意,您也省略了<tbody>元素;你应该把其余的行放在其中一个中。

相关问题