Почему мой значок не отображается в Internet Explorer?
Я сделал таблицу с thead
(заголовком); на Mac, и в Firefox все нормально, а вот в Internet Explorer 6 голова просто пропала ...
Есть идеи, почему?
Вот ссылка для проверки: 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> Date*Endroit*Sanction</li>
<li> 29 Mars & 5 Avril*St-Évariste, Beauce # 1*Équipe Rodéo du Qc.</li>
<li> 12 & 19 Avril*St-Évariste, Beauce # 2*Équipe Rodéo du Qc.</li>
<!-- ... -->
</ul>
Ответов (2)2
Что ж, раз я автор 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();
});
};
Это должно сработать.
You're including <th>
elements directly in the <thead>
group; that's not actually legal. You must enclose them in a <tr>
element, and put that in the <thead>
...
See: 11.2.3 Row groups: the THEAD, TFOOT, and TBODY elements
So modify jQuery.fn.tablerize()
to insert a <tr>
within the <thead>
before appending the <th>
elements:
table = $('<table>');
var thead = $('<thead>');
var headRow = $('<tr>');
$.each(values, function(y) {
headRow.append($('<th>').html(values[y]));
});
thead.append(headRow);
table.append(thead);
Note that you're also omitting the <tbody>
element; you should probably put the rest of the rows in one of those as well.