JsTree

 $("-sharpjurisdictionBox").on("changed.jstree", function (e, data) {  
       console.log(data.selected);
       console.log(data)
 }); 

data:[
  {
                    "id":"00",
                    "text": "",
                    "state": {
                        "selected": false
                    },
                },
                {
                    "id":"01",
                    "text":"",
                     "children": [{
                         "id":"0101",
                        "text": "",
                        "state": {
                           "selected": false
                         }
                        }, {
                            "id":"0102",
                            "text": "",
                            "state": {
                              "selected": false
                             }
                        },
                    ]
                }
]

now the requirement is to know the id of the selected node. How to traverse the original data to make the selected node"s "selected": the selected attribute of false is saved to the background as true,

Feb.27,2021

the requirement now is to know how to traverse the id of the selected node to make the selected node "selected": the selected attribute of false is true
. What else to do with combing
var data = [
  {
    id: '00',
    text: '',
    state: {
      selected: false,
    },
  },
  {
    id: '01',
    text: '',
    children: [
      {
        id: '0101',
        text: '',
        state: {
          selected: false,
        },
      },
      {
        id: '0102',
        text: '',
        state: {
          selected: false,
        },
      },
    ],
  },
]

var selected = ['00', '0101']

var iterative = (data, callback) => {
  if (Array.isArray(data)) {
    data.forEach(item => {
      if (item.children && item.children.length) {
        iterative(item.children, callback)
      }
      callback(item)
    })
    return
  }
  callback(data)
}

iterative(data, item => {
  if (selected.includes(item.id)) {
    item.state.selected = !item.state.selected
  }
})
console.log(data)
Menu