2009-02-25 4 views
2

Ich habe eine Tabelle mit einem thead (Header) gemacht; auf einem Mac, und in Firefox ist alles in Ordnung, aber auf Internet Explorer 6 ist der Kopf einfach weg ...Warum erscheint mein Thead nicht im Internet Explorer?

Irgendeine Idee warum?

Hier ist der Link zu testen: http://www.acecrodeo.com/new/05-rodeos.php ... Die Tabelle in tablerize.js aufgebaut ist:

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(); 
    }); 
}; 

... aus einer Liste auf der Seite:

<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

Ich finde überhaupt keinen Thead im Code ... – Guffa

+0

Die Tabelle wird von JS aus einer Liste erstellt. – Shog9

Antwort

5

Nun, da ich der Autor von Tablerize bin, könnte ich es genauso gut beheben.

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(); 
    }); 
}; 

Das sollte es tun.

+1

++ Schön, Paolo - Weg, hinter deiner Arbeit zu stehen. :-) – Shog9

6

Du bist einschließlich <th> Elemente direkt in der <thead> Gruppe; das ist nicht wirklich legal. Sie müssen sie in einem <tr> Element umschließen und setzen dass im <thead> ...

See: 11.2.3 Row groups: the THEAD, TFOOT, and TBODY elements

So jQuery.fn.tablerize() ändern, um eine <tr> im <thead> einzulegen, bevor die <th> Elemente anhängen:

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

Beachten Sie, dass Sie auch das <tbody> Element weglassen; Sie sollten den Rest der Zeilen wahrscheinlich auch in einen von denen einfügen.