这是我的目标:
var testing = {
"total": {
"q1": "10,000€",
"q2": "20,000€",
"q3": "19,000€",
"q4": "210,000€"
},
"new": {
"q1": "10,000€",
"q2": "20,000€",
"q3": "19,000€",
"q4": "210,000€"
},
"renewal": {
"q1": "10,000€",
"q2": "20,000€",
"q3": "19,000€",
"q4": "210,000€"
}
}
我想循环显示与“total”相关的数据,我不知道如何专门从"total"
获取值。以下不起作用:(
$.each(testing, function(i, item) {
$("#kpi-table").find('tr.total td').each(function (i, el) {
$(this).html(item[0].[i]);
});
});
HTML
<table id="kpi-table" class="table table-striped">
<thead>
<th></th>
<th>Q1</th>
<th>Q2</th>
<th>Q3</th>
<th>Q4</th>
<th>Month</th>
</thead>
<tbody>
<tr class="total">
<td>Total</td>
<td class="q1"></td>
<td class="q2"></td>
<td class="q3"></td>
<td class="q4"></td>
<td></td>
</tr>
..