Created
February 19, 2014 14:44
-
-
Save tron1point0/9093495 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
var color_stuff = function(selector,classes) { | |
var nth_of_type = function(len,i) { | |
return ':nth-of-type(' + len + 'n+' + i + ')' | |
}; | |
var nested = function(c) { | |
return function() { | |
var cs = classes.filter(function(e) { return e !== c }); | |
for (var i = 0; i < cs.length; i++) | |
$(this).children(selector + nth_of_type(cs.length,i)) | |
.each(nested(cs[i])); | |
$(this).addClass(c); | |
}; | |
}; | |
nested(classes[0]).call(this); | |
}; | |
color_stuff.call($('#comments'),'div',['color-1', 'color-2', 'color-3']); | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment