Colleagues, I have the divs:
<!-- question 0 -->
<div id="question 0">
<!-- stars -->
<div class="1 ratings_stars"></div>
<div class="2 ratings_stars"></div>
<div class="3 ratings_stars"></div>
<div class="4 ratings_stars"></div>
<div class="5 ratings_stars"></div>
<!-- text -->
<div class="question_text">
What do you think about us ?
</div>
</div>
I’m looking for smart jquery expression to set defined class to div “Question 0” in such way: I read values, for example, 3 from cookies and therefore I have to change the class in div 1, div 2, div 3. – this is rating for question.
I understand that I can write DOM-handling code to set it, but, may be, there is good cute solution in jquery?
First, the space in
idis forbidden. Change it to a hyphen,-or underscore,_.You can use the
.slicemethod to reduce the selected set of stars: