12345678910111213141516171819202122232425262728293031323334353637 |
- document.querySelectorAll('.accordion-item__trigger').forEach((item) =>
- item.addEventListener('click', () => {
- const parent = item.parentNode;
- const link = parent.querySelector('.link-item');
- if (parent.classList.contains('accordion-item--active')) {
- parent.classList.remove('accordion-item--active');
- } else {
- document
- .querySelectorAll('.accordion-item')
- .forEach((child) => child.classList.remove('accordion-item--active'))
-
- parent.classList.add('accordion-item--active');
-
- }
- if (link.classList.contains('link-item--active')) {
- link.classList.remove('link-item--active');
- } else {
- document
- .querySelectorAll('.link-item')
- .forEach((child) => child.classList.remove('link-item--active'))
-
- link.classList.add('link-item--active');
-
- }
- // if (parent.classList.contains('accordion-item--active')) {
- // link.style.color = 'gray';
- // } else {
- // link.style.color = 'blue';
- // }
-
- })
- )
|