In this article we will see how to select EVEN and ODD elements from the DOM. We can get all children elements using the various methods available for selecting children elements. But for selecting only EVEN or ODD elements needs some changes in you code. :)
So lets see how to get the ONLY Even and Odd elements.
Considering you have below HTML structure of UL and LI, now we will select all even and odd li from the DOM. After selecting elements we will assign class even_li to even elements and odd_li to odd elements
Slick is the element selector engine used by MooTools.
Select ODD Elements using MooTools
Below code will select Odd elements from the UL and add odd_li class to that elements.
Select EVEN Elements using MooTools
Below code will select Even elements from the UL and add even_li class to that elements.