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 7586531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T19:27:05+00:00 2026-05-30T19:27:05+00:00

Markup: <ul> <li> <ul id=ratx> <li>Location</li> <li class=bar><span></span></li> <li class=value>4</li> </ul> </li> <li> <ul

  • 0
Markup:
<ul>
  <li>
    <ul id="ratx">
      <li>Location</li>
      <li class="bar"><span></span></li>
      <li class="value">4</li>
    </ul>
  </li>
  <li>
    <ul id="ratx">
     <li>Hotel Services</li>
     <li class="bar"><span></span></li>
     <li class="value">5</li>
    </ul>
  </li>
  <li>
    <ul id="ratx">
      <li>Hotel Facilities</li>
      <li class="bar"><span></span></li>
      <li class="value">3</li>
    </ul>
  </li>
  <li>
    <ul id="ratx">
      <li>Room Cleanliness</li>
      <li class="bar"><span></span></li>
      <li class="value">4</li>
    </ul>
  </li>
  <li>
    <ul id="ratx">
      <li>Value for Money</li>
      <li class="bar"><span></span></li>
      <li class="value">1</li>
    </ul>
  </li>
</ul>

I want to represent User Ratings dynamically using JQuery so I made a function like this,

jQuery:
$("ul#ratx").each(function(index) {
var val = $(this).children(".value").text();
var barval = val * 40;

/* compute ratings */ 
$("li.bar span").css("width", barval);

});

Now, when I alert barval I get all 5 values but when I try to apply the “compute ratings” line, all it does is apply the last value that it finds. How should I go about this?

Sorry if the question is a confusing. I am not quite sure how to phrase everything.

  • 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-30T19:27:06+00:00Added an answer on May 30, 2026 at 7:27 pm

    The problem is that, while interating through each elements it find, it is applying a common value to all li.bar span. You should represent a single element, you are trying to apply to.

    $(this).children("li.bar span").css("width", barval);

    Update

    Here is a working Demo

    The snippet that worked was

    $(this).find("li.bar").children("span").css("width", barVal );
    

    Also, I changed the display property of the span to display: inline-block;

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The Markup: <div class=day> <span>1</span> <div class=icon-shop icon-blank><p class=event-details id=shop-1></p></div> <div class=icon-eat icon-blank><p class=event-details
Markup: <div id=topMenu <ul class=topnav> <li class=misReservas><a title= href=# class=misReservas><span>MIS RESERVAS</span></a></li> <li class=misOfertas><a title=
HTML markup: <ul id=portfolio><li class=web> <span class=info>August 2007 <a href=http://awebsite.com rel=external>visit</a></span> <a href=/assets/image.jpg class=fancybox
My markup looks like: <div class=c1> <li class=c2><a href=>blah</a></li> </div> I want the text
Markup <div> <label class=form-label-medium>Full Notice Text</label> <span id=FullNoticeText> Lorem ipsum dolor sit amet, consectetur
I have the following markup, and I want to make the All radio button
Given the following markup: <ul> <li>apple</li> <li class=highlight>orange</li> <li>pear</li> </ul> Both the ul s
I have markup like this: <p>one two three four</p> And I want to use
Markup: <div class=modal-body> <p>One fine body…</p> </div> Why isn't this help? $(.modal-body).val = data_per_folder[current_folder.folder_id].data_per_page[current_page].attachment_extraDetails[attachmentId].attachments_markup;
Markup: <div class=foo> <img src=loading.gif class=loading style=display: none; /> </div> Js: $(div[class='foo']).click(function(e) { e.preventDefault();

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.