[英]How to add nested ul and li?
我有以下回應:
var resp = {
name: "menu svc", // some basic info about the menu, not displayed in UI
style: "topmenucontainer",
childstyle: "topmenu",
type: "MENU",
"nodes": [{ // has the menu hierarchy info
name: "Process",
href: "some url",
embedData: "true",
instances: [{
"title": "Proc1",
"url": ""
}, {
"title": "Proc2",
"url": ""
}, {
"title": "Proc3",
"url": ""
}],
nodes: [{
name: "Documents",
href: "url3",
embedData: "true",
instances: [{
"title": "Doc1",
"url": "url1"
}, {
"title": "Doc2",
"url": "url2"
}],
nodes: []
}]
}]
};
我必須基本上創建一個菜單結構,如下所示:
Process
Proc1---------------->Documents
Proc2 Doc1-------------------------->
Proc3 Doc2
因此,特定節點的所有實例將在該節點下以li列出,而每個子節點在每個父節點實例內都應以ul列出。 同樣,它的遞歸結構作為子節點將包含子節點,並且應以類似方式顯示。
有指針嗎?
謝謝
您可以嘗試以下方法:
$("#header ul").append('<li><ul><li></li><li></li><li></li></ul></li>');
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div id="header"> <ul> </ul> </div>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.