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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:20:20+00:00 2026-06-13T14:20:20+00:00

For example we 5 DIVs: <div id=container > <div class=child>1</div> <div class=child>2</div> <div class=child>3</div>

  • 0

For example we 5 DIVs:

<div id="container" >
  <div class="child">1</div>
  <div class="child">2</div>
  <div class="child">3</div>
  <div class="child">4</div>
  <div class="child">5</div>
</div>

How can I change the background color of even DIVs?

  • 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-06-13T14:20:22+00:00Added an answer on June 13, 2026 at 2:20 pm

    If you wanted a javascript option for some reason (maybe you’re looking to do more than just a class?) you could use the each() function in jquery. Here is a functioning example to boot!

    CSS

    .redBox{
        background-color: #ff0000;
    }​
    

    Javascript

    var i = 0;
    $(".child").each(function(i){
        if(i%2===0){
            $(this).addClass("redBox");
        }
        i++;
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two divs: <div class=outer> <div class=inner>Example</div> </div> And I have a jQuery
Example Div: <div class=container> <div class=select1></div> <div class=select2></div> <div class=select3></div> </div> Now I want
I have multiple divs on the site! for example <div id='id_111232'>Some text</div> <div id='id_111233'>Some
Let's have an example: <div class=gg-1></div> // 1 <div class=gg-1></div> // 1 <div class=gg-1></div>
If I have the following: <div class=apple-monkey></div> <div class=apple-horse></div> <div class=cow-apple-brick></div> I can use
I have 3 divs within a div container, I loop through each of them.
In my html page i have two divs inside a container div. The two
I have a parent div with a variable number of equally sized child divs
I have an example DOM as such below where new child elements can be
I'm trying to move child div elements between two different parent divs using jQuery

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.