Is it possible to write individual code for each result within an .each() function?
What I’d like to do in the example is have each line item to have a unique color. Can this be done within the .each() ?
$(document).ready(function() {
$('li').each(function() {
$(this).css('color', 'purple');
});
// End it all
});
Edit: To be more concise, is it possible to add unique css to each item? Not just a color for example but say I wanted to have the first item have a font-weight of bold and the next item be italic…
yeah You can do this using the following code
Working Fiddle
Put your colors in
colorsarray.Update
You can define different css for each li in a array like this
Working Fiddle
You have define the
cssproperty’s as'key':'value'pair incssarray of objects.