1. 前端代码
<div id="goodslable"></div>
2. js代码
function loadList() {
var UlStr = '<ul class="HallItems" id="item">';
$.ajax({
url: '', //接口
dataType: 'json',
type: 'get',
async: false,
success: function (result) {
var data = result.data;
for (var i = 0; i < data.length; i++) {
var node = ('<li class="item" id="' + i + '" style="float:left;margin:10px;"></li>');
UlStr += node;
}
}
});
return UlStr + "</ul>";''
}
$("#goodslable").append(loadList());