Home > Forum > Forms > Callapse the categories in attachments

Callapse the categories in attachments
0

Please check this code.

To show:

const divs = document.querySelectorAll('.table-tree');

divs.forEach(div => {
const uls = div.querySelectorAll('ul');

uls.forEach((ul, index) => {
if (index > 0) {
ul.classList.remove('hidden');
}
});
});

To hide:

const divs = document.querySelectorAll('.table-tree');

divs.forEach(div => {
const uls = div.querySelectorAll('ul');

uls.forEach((ul, index) => {
if (index > 0) {
ul.classList.add('hidden');
}
});
});