124
rated 0 times
[
128]
[
4]
/ answers: 1 / hits: 17817
/ 12 Years ago, mon, april 30, 2012, 12:00:00
I'm trying to select every third element of a parent with javascript and add a css class to it. Sounds pretty simple to me but I can't get it work.
I found this thread which looked quite nice to me to get that done, but I'm such a wuss with javascript that my tries didn't work out:
var nodes = document.getElementsByClassName(ParentsClassName).childNodes;
for(i=0; i<nodes.length; i+=3) {
this.className += ' newClassName';
}
When I load this, nothing happens at all.
Any fixes, eyeopeners and tips appreciated.
Greetings, Marian
More From » selector