Home » Jquery » jquery – How to get selected item group name in "loudev" multi-select-Exceptionshub

jquery – How to get selected item group name in "loudev" multi-select-Exceptionshub

Posted by: admin February 24, 2020 Leave a comment

Questions:

For Ex:

enter image description here

If select ‘Yoda’ I want to get that group name ‘Friends’ in the loudev afterSelect method.

How to&Answer:

enter image description here

I got a solution. The above ref image is lou-dev multi-select rendered elements.

So first we find selected item element with that name.

Next we get that near by li with .ms-optgroup-label class name

The code ref:

afterSelect: (selectedVals) => { //selectedVals=[Yoda]
  $(`span:contains('${selectedVals[0]}')`).first().closest('li').siblings('li.ms-optgroup-label').text()
}