Friday 15 April 2011

asp.net - jQuery: adding a class to child elements x number of times -


I have a Dave star performs the racquet which displays 5 graded-out stars. I have been given a number and depending on the number, I need to add a CSS class which turns the grade-out star into a colorful color. Is there anything that I can complete for a loop or with it? what?

Here's HTML:

  & lt; Div id = "star rating" & gt; & Lt; Div class = "jquery-ratings-star" & gt; & Lt; / Div & gt; & Lt; Div class = "jquery-ratings-star" & gt; & Lt; / Div & gt; & Lt; Div class = "jquery-ratings-star" & gt; & Lt; / Div & gt; & Lt; Div class = "jquery-ratings-star" & gt; & Lt; / Div & gt; & Lt; Div class = "jquery-ratings-star" & gt; & Lt; / Div & gt; & Lt; / Div & gt;   

And this is what I am trying to do. It seems that I am engaging it.

  $ ('.jquery-ratings-star'). Each (function () {for (var i = 0; i & lt; nbrStarsVoted; I ++) {$ (this) .addClass ('.jquery-ratings-full');}});    

Simple in this form,

  $ ( '#RarRetting Div: LT (' + NBR StarWit + ')' ' Adquass ('jquery-ratings-full');   



No comments:

Post a Comment