我有以下代码
$.get('feed.txt', function(data) {
var arr = data.split('|');
var values = '';
for(var i=0; i<arr.length; i++){
values += '<div>'+arr[i]+'</div>';
}
$('div').html(values);
});
我想根据文本文件(下面的示例)提供的信息向生成的 div 添加一个类,即如果 type="small" 那么我想添加 class="small"
TYPE: Small, ID: 0001, RESPONSE DATE AND TIME: 2012-12-12 12:00, UNITNAME: Name, MEMO: Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.|
TYPE: Medium, ID: 0002, RESPONSE DATE AND TIME: 2012-12-12 01:00, UNITNAME: Name, MEMO: Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.|
TYPE: Large, ID: 0003, RESPONSE DATE AND TIME: 2012-12-12 02:00, UNITNAME: Name, MEMO : Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.|