使用jQuery添加表行-IE7特定问题
仍然掌握jQuery的诀窍,我在向表中添加行时遇到了问题。我从中获得了代码,但它在IE7上不起作用,不幸的是,IE7是一款浏览器 我认为问题在于表的jQuery选择器,但我尝试过的其他方法都不起作用。有什么想法吗 一些代码:使用jQuery添加表行-IE7特定问题,jquery,Jquery,仍然掌握jQuery的诀窍,我在向表中添加行时遇到了问题。我从中获得了代码,但它在IE7上不起作用,不幸的是,IE7是一款浏览器 我认为问题在于表的jQuery选择器,但我尝试过的其他方法都不起作用。有什么想法吗 一些代码: <table id="payments" class="resultsGrid"> <thead> <tr class="header"> <th style="width: 45px
<table id="payments" class="resultsGrid">
<thead>
<tr class="header">
<th style="width: 45px;">Type</th>
<th style="width: 50px;">Check #</th>
<th style="width: 50px;">Amount</th>
<th style="width: 50px;">Date</th>
<th>Notes</th>
<th style="width: 48px;"></th>
</tr>
</thead>
<tbody>
</tbody>
</table>
类型
检查#
数量
日期
笔记
而JS:
var table = $("#payments > tbody:last");
table.empty();
if (demolition.Payments != null) {
$("#payments").show();
for (i = 0; i < demolition.Payments.length; i++) {
table.append("<tr>");
// blah blah trimmed
table.append("</tr>");
}
}
else {
table.append("<tr>");
table.append("<td colspan=\"6\" style=\"padding: 4px;\">No payments recorded.</td>");
table.append("</tr>");
}
var表=$(“#付款>主体:最后一次”);
table.empty();
如果(拆卸付款!=null){
美元(“#付款”).show();
对于(i=0;i
将它们合并到一个调用中。jQuery将关闭标记并添加一行,然后在该行之外添加单元格。甚至Chrome也会在浏览器中显示这种行为
尝试将所有文本附加到一行代码中,而不是三行代码中——有可能开头的TR标记正在立即关闭,而不是等待您完成。您也可以通过
。将
压缩文本到数组中,然后。追加
压缩。一次加入
ed数组。使用table.append和预构建的HTML字符串修复了它。谢谢,丹尼斯。(一旦网站允许,我将接受答案)
table.append("<tr><td colspan=\"6\" style=\"padding: 4px;\">No payments recorded.</td></tr>"); //This adds a row with its contents contained.
var buffer = [];
for (...){
buffer.push("<tr>");
buffer.push(cellOne);
buffer.push(cellTwo);
buffer.push(cellThree);
buffer.push("</tr>");
}
table.append(buffer.join('')); //This speeds up string concatenation.