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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:43:55+00:00 2026-05-13T23:43:55+00:00

I’ve set up a simple jQueryUI progressbar: <script type=text/javascript> $(function() { $(#progressbar).progressbar({ value: 35

  • 0

I’ve set up a simple jQueryUI progressbar:

<script type="text/javascript">
    $(function() {
        $("#progressbar").progressbar({
                value: 35
        });
    });
</script>

<div id="progressbar">  </div>

Now, I’d like to color the of the bar based on it’s value (e.g. <10 red, <50 yellow, >50 green). How do I do this?

Note: There are similar questions, but the answers were not clear enough to help me get things done. Hopefully, someone can point out an easier way or provide more detailed instructions. Thanks.

  • 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-13T23:43:55+00:00Added an answer on May 13, 2026 at 11:43 pm

    I fiddled around with it and here’s what I found. Using jQuery UI v1.8rc3, I can override the theme colors for the progress bar.

    alt text

    Here’s how:
    When you add a progressbar widget to a div, with something like:

    $("#mydiv").progressbar({value:0});
    

    …the jQuery UI progressbar creates a div within your div; this inner div represents the value bar. To set the color of the bar, set the background of
    the child (inner) div.

    You can also set the color of the empty space in the progress bar, the space to the right of the value bar. Do this by setting the background of the outer div.

    For either of these, you can use flat colors, or images. If you use images, then be sure to set the repeat-x. The code to do that, looks like this:

    html:

    <div id='mainObj' class="inputDiv">
      <div id='pbar0' style="height: 20px;"></div>
      <div id='pbar1' style="height: 20px;"></div>
      <div id='pbar2' style="height: 20px;"></div>
      <div id='pbar3' style="height: 20px;"></div>
    </div>
    

    js:

    function init(){
        // four progress bars
        $("#pbar0").progressbar({ "value": 63 });
        $("#pbar1").progressbar({ "value": 47 });
        $("#pbar2").progressbar({ "value": 33 });
        $("#pbar3").progressbar({ "value": 21 });
    
        // the zero'th progressbar gets the default theme
    
        // set colors for progressbar #1
        $("#pbar1").css({ 'background': 'url(images/white-40x100.png) #ffffff repeat-x 50% 50%;' });
        $("#pbar1 > div").css({ 'background': 'url(images/lime-1x100.png) #cccccc repeat-x 50% 50%;' });
    
        // set colors for progressbar #2
        $("#pbar2").css({ 'background': 'url(images/lt-blue-40x100.png) #ffffff repeat-x 50% 50%' });
        $("#pbar2 > div").css({ 'background': 'url(images/dustyblue-1x100.png) #cccccc repeat-x 50% 50%' });
    
        // set colors for progressbar #3
        $("#pbar3").css({ 'background': 'LightYellow' });
        $("#pbar3 > div").css({ 'background': 'Orange' });
    }
    

    ok, that takes care of setting the colors. Now,
    if you want to dynamically set the color of the bar as the value changes, you hook the progressbarchange event, like this:

        $("#pbar0").bind('progressbarchange', function(event, ui) {
            var selector = "#" + this.id + " > div";
            var value = this.getAttribute( "aria-valuenow" );
            if (value < 10){
                $(selector).css({ 'background': 'Red' });
            } else if (value < 30){
                $(selector).css({ 'background': 'Orange' });
            } else if (value < 50){
                $(selector).css({ 'background': 'Yellow' });
            } else{
                $(selector).css({ 'background': 'LightGreen' });
            }
        });
    

    Working demonstration: http://jsbin.com/atiwe3/3


    Note:

    If you want to override the colors for all progressbars the css classes to use are ui-widget-content, for the “background” or outer div, and ui-widget-header for the actual bar (corresponding to the inner div). Like this:

      .ui-progressbar.ui-widget-content {
         background: url(images/white-40x100.png) #ffffff repeat-x 50% 50%;
      }
    
      .ui-progressbar.ui-widget-header {
         color: Blue;
         background: url(images/lime-1x100.png) #cccccc repeat-x 50% 50%;
      }
    

    If you eliminate the .ui-progressbar prefix, it will override the colors of all UI widgets, including progressbars.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to render a haml file in a javascript response like so:
I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I would like to count the length of a string with PHP. The string
I used javascript for loading a picture on my website depending on which small
I have a jquery bug and I've been looking for hours now, I can't
Basically, what I'm trying to create is a page of div tags, each has
this is what i have right now Drawing an RSS feed into the php,

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.