【发布时间】:2012-12-31 00:15:39
【问题描述】:
我在这里真的很困惑..
我正在尝试从表中获取值并将这些值添加到具有类标题的 div 中
附加函数和.text 函数。
问题是,当我使用每个函数时,表中的最后一个值会被附加并且
其余的被跳过..
这是我的代码:
<script type="text/javascript">
$(document).ready(function() {
$('#nameGridView tr').each(function() {
if (!this.rowIndex) return; // skip first row
var productName = this.cells[0].innerHTML;
$('.title').each(function (i, obj) {
$('.title').html(productName);
});
});
});
</script>
请告诉我如何遍历每个表并同时添加,例如第一个 div 标题、表中的第一个值被附加等等。 谢谢。
【问题讨论】:
标签: jquery html-table iteration