men*_*mam 2 html javascript internet-explorer dom
我用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();
});
};
Run Code Online (Sandbox Code Playgroud)
...从页面上的列表:
<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>
Run Code Online (Sandbox Code Playgroud)
你<th>直接在<thead>组中包含元素; 这实际上并不合法.你必须将它们包含在一个<tr>元素中,并把它放在<thead>...中
请参阅:11.2.3行组:THEAD,TFOOT和TBODY元素
因此,修改jQuery.fn.tablerize()插入<tr>内<thead>追加前<th>元素:
table = $('<table>');
var thead = $('<thead>');
var headRow = $('<tr>');
$.each(values, function(y) {
headRow.append($('<th>').html(values[y]));
});
thead.append(headRow);
table.append(thead);
Run Code Online (Sandbox Code Playgroud)
请注意,您也省略了该<tbody>元素; 你应该把剩下的行放在其中一行中.
好吧,因为我是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();
});
};
Run Code Online (Sandbox Code Playgroud)
应该这样做.
| 归档时间: |
|
| 查看次数: |
2849 次 |
| 最近记录: |