Javascript树形json生成<ul><li>
var makeTree = function (parentObj, treeJson) { var ulObj = $("<ul></ul>"); for (var i = 0; i < treeJson.length; i++) { var childHtml = "<li>"; var aHtml = "<a data-id='" + treeJson[i].id + "'>" + treeJson[i].name + "</a>"; childHtml += aHtml; childHtml += "</li>"; var childObj = $(childHtml); if (treeJson[i].children != null && treeJson[i].children.length > 0) { makeTree(childObj, treeJson[i].children); } $(ulObj).append(childObj); } $(parentObj).append($(ulObj)); };