Reputation: 305
I want to print something like this
each bubble u see is a "li" element
so i have made float=left so that i can see them horizontally. I am not able to understand, how should i display two different colors dynamically.
Eg: If it is 60% and 40%, then I need to show more blue bubbles and less orange ones and vice versa.
Upvotes: 1
Views: 104
Reputation: 92953
Can't offer specifics without some specific code of yours, but: use the modulo operator (%
) together with >
or <
.
For instance:
var idx = $('ul li').index();
to get the index, and then
var color = (idx % 11 < 6) ? "blue" : "orange";
to pick the color.
Upvotes: 3