📜  jquery 嵌套 ul li - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:04:32.452000             🧑  作者: Mango

代码示例2
function buildList(data) {
    var $ul = $('
    '); for (const key in data) { var $child = $('
  • '); $ul.append($child) if (typeof data[key] === 'object') { $child.text = $child.text(key); $child.append(buildList(data[key])); } else { $child.text = $child.text(key + ' : ' + data[key]); } } return $ul; }