2009-02-25 159 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>元素;你應該把其餘的行放在其中一箇中。

相關問題