【发布时间】:2015-04-29 07:36:02
【问题描述】:
我目前正在开发一个基于 jQuery 的递归菜单,它看起来已经相当不错了。
包含菜单的 JSon 文件结构如下:
[
{
"Id": "menuOfficeWebControlsForWebApplication",
"Title": "Office Web Controls",
"Resource": "/Documentation/Data/index.html" },
{
"Id": "menuGettingStarted",
"Title": "Getting Started",
"Resource": "/Documentation/Data/getting-started.html",
"Categories": [{
"Id": "menuCompilingFromSource",
"Title": "Compiling From Source",
"Resource": "/Documentation/Data/Getting-Started/compiling-from-source.html"
},{
"Id": "menuDownloadReleasePackage",
"Title": "Download Release Package",
"Resource": "/Documentation/Data/Getting-Started/downloading-release-package.html"
},{
"Id": "menuBuildingYourFirstApplication",
"Title": "Building your first application",
"Resource": "/Documentation/Data/Getting-Started/building-your-first-application.html"
}]
}
]
现在,我可以使用 jQuery 从菜单中检索一个项目,结果可能是这个项目:
{
"Id": "menuBuildingYourFirstApplication",
"Title": "Building your first application",
"Resource": "/Documentation/Data/Getting-Started/building-your-first-application.html"
}
现在,我想检索更高级别的所有元素以及该项目正下方的所有项目。
非常感谢任何帮助。
【问题讨论】:
-
什么是父母?任何不是当前节点的节点?你能改变节点吗(例如添加 ParentNode 属性)
-
我可以那样做,但很容易出现拼写错误。父级是层次结构中较高的元素。
标签: javascript jquery css json