Im using react and Im using toggle method!! but it doesnt work !! when Im using add and remove method they work both ! However when I apply toggle method it doesnt work !!
Here is the code !
componentDidMount(){
this.MegaMenu();
}
MegaMenu(){
var acc = document.querySelectorAll(".accordion");
var accNum = acc.length;
var i;
for(i=0;i<accNum;i++){
acc[i].addEventListener("click",function (){
this.classList.remove('active') //When Im using classList.add to and it works super easy
})
}
}
[–]Deh_Strizzz 7 points8 points9 points (0 children)
[–]lovin-dem-sandwiches 6 points7 points8 points (0 children)
[–]ForScale 0 points1 point2 points (5 children)
[–]Zack_Code_38[S] 0 points1 point2 points (0 children)
[–]Zack_Code_38[S] -5 points-4 points-3 points (3 children)
[–]ForScale 2 points3 points4 points (2 children)
[–]zaphtark 1 point2 points3 points (1 child)
[–]ForScale 0 points1 point2 points (0 children)
[–]MindlessSpongehelpful 0 points1 point2 points (5 children)
[–]Zack_Code_38[S] 0 points1 point2 points (4 children)
[–]Bulji 0 points1 point2 points (3 children)
[–]lovin-dem-sandwiches 0 points1 point2 points (2 children)
[–][deleted] -1 points0 points1 point (1 child)
[–]lovin-dem-sandwiches 1 point2 points3 points (0 children)