JS代码:
[javascript] view plaincopyprint?
var typeData;
$.getJSON("../data/GetTypeData.aspx", { "resultType": "json" }, function(data, textStatus) {
typeData = data;
var arrayparent = new Array();
for (var i = 0; i < data.length; i++) {
if (data[i].ParentId == 0) {
arrayparent.push(data[i]);
}
}
//添加一级标签
var parentDiv = document.getElementById("Category_LeftTag");
for (var j = 0; j <= arrayparent.length - 1; j++) {
$('<li class="leftpanel" onclick="btnOK(this,1,' + arrayparent[j].id + ')" value="' + arrayparent[j].id + '" onmouseover="" onmouseout="mouseOut(this)">' + arrayparent[j].name + '</li>').appendTo(parentDiv);
}
}
)
//根据父ID获得子类
function GetChildData(id, data) {
var childData = new Array();
for (var i = 0; i < data.length; i++) {
if (id == data[i].ParentId) {
childData.push(data[i]);
}
}
return childData;
}