user564927
user564927

Reputation: 305

Regarding bubble display in jquery

I want to print something like thisenter image description here

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

Answers (1)

Blazemonger
Blazemonger

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

Related Questions