2009-02-25 4 views
2

thead (헤더)이있는 테이블을 만들었습니다. Mac 및 Firefox에서 모든 것이 정상이지만 Internet Explorer 6에서는 머리가 사라졌습니다.왜 Internet Explorer에 내 테드가 나타나지 않습니까?

이유가 무엇입니까? http://www.acecrodeo.com/new/05-rodeos.php 표는 tablerize.js 구성되어 ... :

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

+0

테이블은 JS에서 목록으로 작성됩니다. – Shog9

답변

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

그렇게해야합니다.

+1

++ Nice, Paolo - 당신의 일을 견디는 길. :-) – Shog9

6

여기

그것을 테스트 할 수있는 링크입니다 <th> 요소를 <thead> 그룹에 직접 포함; 그것은 실제로 합법적이지 않습니다. 당신은 ... <tr> 요소에 묶하고 <thead>를 삽입해야합니다

참조 : 11.2.3 Row groups: the THEAD, TFOOT, and TBODY elements

는 그래서 <th> 요소를 추가하기 전에 <thead> 내에서 <tr>를 삽입 jQuery.fn.tablerize()을 수정

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> 요소도 생략한다는 점에 유의하십시오. 당신은 아마 그 중 하나에 나머지 행을 넣어야합니다.