日期:2014-05-16 浏览次数:20457 次
[{ "approved": "我我的", "kkli": "生生世世" }, { "approved": "你你的", "kkli": "生生世世" }, { "approved": "哈哈哈", "kkli": "生生世世"}]
</table>
<table id="hidden_attr" style="display:none;">
<tbody class="add_item_attr">
<tr>
<th width="200">
<a href="javascript:void(0);" class="blue" onclick="del_attr(this);"><img src="__STATIC__/css/admin/bgimg/tv-collapsable.gif" /></a>材料 :<input type="text" name="attr[name][]" class="input-text" size="20">
</th>
<td>用量 :<input type="text" name="attr[value][]" class="input-text" size="30"></td>
</tr>
</tbody>
$(function(){
var data = [{ "approved": "我我的", "kkli": "生生世世" }, { "approved": "你你的", "kkli": "生生世世" }, { "approved": "哈哈哈", "kkli": "生生世世"}] ;
var _length = $('tr' , $('#hidden_attr')).length;
var html = '';
$.each(data , function(i , o){
if(_length > i){
var obj = $('#hidden_attr tr').children('th , td');
obj.eq(0).children(':text').val(o.approved);
obj.eq(1).children(':text').val(o.kkli);
}else{
html+='<tr>\
<th width="200">\
<a href="javascript:void(0);" class="blue" onclick="del_attr(this);">\
<img src="__STATIC__/css/admin/bgimg/tv-collapsable.gif" />\
</a>\
材料 :<input type="text" name="attr[name][]" value="' + o.approved + '" class="input-text" size="20">\
</th>\
<td>\
用量 :<input type="text" name="attr[value][]" value="' + o.kkli + '" class="input-text" size="30">\
</td>\
</tr>';
}
});
$('#hidden_attr').append(html);
});