I am trying to get even (div)elements and give them different class Names compared to odd (div) elements in which they will have different class names also, I want to write inside querySelectorAll() function to get even (.project) class and to get odd (.project) class without providing index like [0], [1],...etc. is there a way to do something like that? here is there code for explanation.
here is the original code:
document.querySelectorAll('.project')[0].classList.add('EvenProject');
document.querySelectorAll('.project')[1].classList.add('OddProject');
document.querySelectorAll('.project')[2].classList.add('EvenProject');
here is what I want to implement:
document.querySelectorAll('.project:even').classList.add('EvenProject');
document.querySelectorAll('.project:odd').classList.add('OddProject');
I also tried this code, by querySelector(), but It doesn't work.
document.querySelector('.project:even').classList.add('EvenProject');
thanks for you help.