Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7517085
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:20:06+00:00 2026-05-30T01:20:06+00:00

Colleagues, I have the divs: <!– question 0 –> <div id=question 0> <!– stars

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T01:20:08+00:00Added an answer on May 30, 2026 at 1:20 am

    First, the space in id is forbidden. Change it to a hyphen, - or underscore, _.

    You can use the .slice method to reduce the selected set of stars:

    var stars = 3; // From cookie?
    var $div = $('#question-0');
    $div.children('.rating_stars').slice(0, stars).addClass('rating-color');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Colleagues, I have the such question: 1. In my first class I have the
Today my colleagues and me have a discussion about the usage of the final
Yesterday, I have a discussion with my colleagues about HTTP. It is asked why
We had a talk with colleagues about databases yesterday as we will have a
I have a couple of colleagues looking at some bad code in Excel VBA,
i have small problem understanding why my smart pointer class is leaking on self
My colleagues and I have some misunderstandings about the .NET runtime. I've written a
Me and my colleagues have a question regarding SQL Server 2008 query length and
Colleagues, Preamble. My question is more about best practices. I know one workaround. This
I've asked this question of a few colleagues who I believe have good design

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.