递归

// tree list
function tree_list(datalist) {
var html = '';
$.each(datalist, function (index, data) {
html += '<ul class="hr_ul1 change">';
html += '<li class="hr_left_1" cussortid="' + data["id"] + '"><span>' + data['name'] + '&nbsp;<em class="list_num_null">(<i></i>)</em></span></li>';
if (data['children'] && data['children'].length > 0) {
html += tree_list(data['children'])
}
html += '</li>';
html += '</ul>'
});
return html
}

posted @ 2017-06-17 22:38  likwin  阅读(112)  评论(0编辑  收藏  举报