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

  • Home
  • SEARCH
  • 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 8129681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T08:23:46+00:00 2026-06-06T08:23:46+00:00

I have a home page with ul li div the div is a square

  • 0

I have a home page with ul li div the div is a square box and i have 3×3 at the top.
The bottom section of my site is code generated mark up and i have something similar.

I would like to give each div “box” a color, currently they are all styled with css. Is there a way with jquery to check for ul li div and if the div exists then add a DIFFERENT colour to the inline style? I would need to store the colors in the script.

This is how i could start?:

$("div.box").css({"background-color": "color"});

Here is my example cut down markup:

<ul>
<li data-target="aboutme" data-target-activation="click" style="margin-top:0px" class="tile high me">
          <div>
          <h2>About Me</h2>
        <h3></h3>
         <img width="48" height="48" alt="" class="icon" src="images/icons/x.png">
     </div>
</li>

<li data-target="aboutme" data-target-activation="click" style="margin-top:0px" class="tile high me">
          <div>
          <h2>Pane 2</h2>
        <h3></h3>
         <img width="48" height="48" alt="" class="icon" src="images/icons/x.png">
     </div>
</li>

<li data-target="aboutme" data-target-activation="click" style="margin-top:0px" class="tile high me">
          <div>
          <h2>Pane 3</h2>
        <h3></h3>
         <img width="48" height="48" alt="" class="icon" src="images/icons/x.png">
     </div>
</li>
</ul>

This is the css:

       .tiles {
        height: 95%;
        margin: 0 auto;
        min-height: 950px;
        overflow: visible;
        padding: 10px;
        width: 957px;
    }

    .tile.high {
    float: left;
        height: 200px;
        margin-top: -100px;
        padding-left: 10px;
        width: 23.6%;
    }

    li.tile div {
        background-color: #00ABA9;
    }

    .tile div {
        background-repeat: no-repeat;
        height: 100%;
        margin: 10px 10px 0;
        overflow: hidden;
        width: 100%;

    }
  • 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-06T08:23:48+00:00Added an answer on June 6, 2026 at 8:23 am

    Loop through div’s and use different color on each:

    // Declare colors you want to use
    var myColors = [
        '#f00', '#abc', '#123'
    ];
    var i = 0;
    $('div.box').each(function() {
        $(this).css('background-color', myColors[i]);
        i = (i + 1) % myColors.length;
    });
    

    Check online: http://jsfiddle.net/4NVRQ/

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

Sidebar

Related Questions

I have some code that fades in the container div of the home page
I have built a site in wordpress and the home page is really screwed
I have an existing site that requires a background image on the home page.
I have a div on my home page which uses a jQuery plugin called
I have a menu: <div class=headerMenu> <ul> <li><a href=#>Home <span>Home Page<span></a></li> <li><a href=#>About <span>About
I have 3 boxes that i have at the bottom of my home page,
I have a facebook like button in my web site in the home page.
I have an application built using JSF1.2. I have a home page which has
On my home page i have roughly 10 grids that sit inside ajax tabs
I have an ASP.NET home page where user provides his login ID. Depending on

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.