javascript - How to select the node corresponding to the attribute structure and obtain the corresponding id and parent id
淡淡烟草味
淡淡烟草味 2017-05-19 10:29:19
0
1
517

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...

淡淡烟草味
淡淡烟草味

reply all(1)
仅有的幸福

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.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template