how to toggle class of parent in javascript code example
Example 1: how to toggle class of parent in javascript
const toggleLink = (element) => {
element.parentNode.classList.toggle('closed');
}
Example 2: how to toggle class in children element
menuAnimate = () => {
const main = document.getElementById('menuIcon');
main.classList.toggle('rotate');
let c = document.getElementById('menuIcon').children;
c[0].classList.toggle('rotateL');
c[1].classList.toggle('slick');
c[2].classList.toggle('rotateR');
}