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.
Below code will select Odd elements from the UL and add odd_li class to that elements.
Below code will select Even elements from the UL and add even_li class to that elements.
Avinash Zala is leading various projects which deals with the various technology involved with the web. A combination of perfect technical and management skills. Avinash would like to chat with you and convert your imagination into the working system. You can get in touch with him on Facebook and Twitter.
View all posts by: Avinash