Am I still learning jQuery and running into something that I just can't wave my head at? (I'm not very good at math!). I know that maybe there is a graph type plugin that I could use, but I don't know if I need something so bulky / heavy. Any help would be greatly appreciated. This site is the best source for learning online!
I am trying to figure out how I could look at a list of comments that have a rating of excellent / good / good / bad contained in a div in li's comment. Then work out the percentage of excellent / good / good / weak comments, based on the fact that many comments are, for example: if there are only 4 comments, and there are 3 products and 1 bad, then it will be 75% good and 25% poor.
Then, to display these percentages, using the width property for each of the corresponding DIV files of the percentage bar.
Sorry if this is not clear, I thought it would be so simple, but I'm at a dead end. Please see the markup below to understand what I'm trying to do.
Any help would be awesome! :)
COMMENT // These will be li comments with excellent / good / good / low ratings inside them. They will be wrapped in UL with id 'comments'
<li> <p>blah blah blah...</p> <div class="user-image"></div> <div class="okay">It okay</div> </li> <li> <p>blah blah blah...</p> <div class="user-image"></div> <div class="excellent">It okay</div> </li> <li> <p>blah blah blah...</p> <div class="user-image"></div> <div class="okay">It okay</div> </li> <li> <p>blah blah blah...</p> <div class="user-image"></div> <div class="poor">It okay</div> </li> <li> <p>blah blah blah...</p> <div class="user-image"></div> <div class="poor">It okay</div> </li> <li> <p>blah blah blah...</p> <div class="user-image"></div> <div class="good">It okay</div> </li> <li> <p>blah blah blah...</p> <div class="user-image"></div> <div class="good">It okay</div> </li> <li> <p>blah blah blah...</p> <div class="user-image"></div> <div class="good">It okay</div> </li> <li> <p>blah blah blah...</p> <div class="user-image"></div> <div class="good">It okay</div> </li> <li> <p>blah blah blah...</p> <div class="user-image"></div> <div class="okay">It okay</div> </li>
COMMENT // These will be the results, each percentage point is contained in the DIV, which corresponds to the rating excellent / good / good / bad. They will be wrapped in UL with identification "results".
<li> <div class="excellent"> <div class="percentage-bar"></div> </div> </li> <li> <div class="good"> <div class="percentage-bar"></div> </div> </li> <li> <div class="okay"> <div class="percentage-bar"></div> </div> </li> <li> <div class="poor"> <div class="percentage-bar"></div> </div> </li>
source share