The information returned by the tree structure is as follows. When selected, "state": {"selected" : true} will be generated accordingly. Now I want to get the corresponding id when selected and the id of the parent. How to solve it elegantly? ?
[
{
"id": "514600710075631001",
"text": "医院管理",
"state": {
"selected": true
},
"children": [
{
"id": "514600710075631106",
"text": "职称管理",
"state": {
"selected": true
},
"children": [
{
"id": "514600710075631151",
"text": "职称列表"
}
]
},
{
"id": "514600710075631102",
"text": "科室管理",
"children": [
{
"id": "514600710075631121",
"text": "科室列表"
}
]
}
]
}
]
Similar to Demo http://css-tricks.com/example...
仅有的幸福2017-05-19 10:31:19
If you are directly manipulating the DOM, use the parentNode
,如果是框架操作 DOM 则为每个点维护一个 parent
attribute.
Or, don’t change anything, bind events to all nodes, and the bubbling mechanism will automatically traverse it.