I have a range of vibrant colors that I would like to assign to each list item in my unordered list. However, once the number of list items exceeds the number of colors available, I want the colors to cycle back to the beginning color. Take a look at this example:
$(document).ready(function(){
var colors = ['#0098c3', '#bed600', '#a30050', '#9b1889'];
$('#div_id ul li').each(function(i){
$(this).css('backgroundColor', colors[i % colors.length]);
});});
Thank you in advance!