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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:45:41+00:00 2026-05-30T18:45:41+00:00

How to alternate style (background color with jQuery) for div inside div with id=container

  • 0

How to alternate style (background color with jQuery) for div inside div with id="container" alternately (even and odd) if I have HTML like this:

<div>
    <span>10%</span>
</div>
<div>
    <span>20%</span>
</div>
<div>
    <span>30%</span>
</div>
.....
.....

How can I select the divs with above 50% and highlight them using 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-30T18:45:43+00:00Added an answer on May 30, 2026 at 6:45 pm

    This seems to answer your original question: http://jsfiddle.net/DRMZz/1/

    jQuery(document).ready(function() {
    
        var text = jQuery('span').text();
    
        var textArray = text.split('%');
    
        for (var i = 0; i < textArray.length; i++) {
            if((parseInt( textArray[i] )) > 50){
                var spanSelector = 'span:eq(' + i + ')';
                console.log(spanSelector);
                jQuery(spanSelector).css('background','yellow');
            }
        };
    

    });​

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

Sidebar

Related Questions

Given the following html: <body> <div style=float: left; background: red>Hi</div> <div style=float: left; background:
I want to style alternate item in a list with a background color of
This alternate & normal give different color to the background of the rows If
I have this jQuery based CSS style switcher in my webpage. When I updated
I have a custom style file( style.xml ) in res/values that looks like this:
I have code sort of like this: <div class=right_col> <div class=right_box> <div class=other_div>text</div> text
i would to have alternate 2 colors of rows, like the first black, the
Can we have alternate Row color to GtkMenu items? and how to increase menu
I have a jquery fullcalendar . I would like to trigger jquery QTip (or
I have a static html table on a page and i would like to

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.