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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T21:48:42+00:00 2026-06-07T21:48:42+00:00

I have the following basic HTML: <div class=row-wrapper> <div class=box>…</div> <div class=box>…</div> </div> …and

  • 0

I have the following basic HTML:

<div class="row-wrapper">
  <div class="box">...</div>
  <div class="box">...</div>
</div>

…and I need to assign an additional class .foo to the inner DIVs that already have the .box class (keeping the .box class of course).

I need a way to detect when there are 2 DIVs inside .row-wrapper

Any idea how I can accomplish this?

I tried reading the jQuery API documentation for .length method but it’s bit too complex for my jQuery knowledge.

I also read a similar forum, but they don’t explain how to define the amount of items.

Any help is greatly appreciated.

  • 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-07T21:48:45+00:00Added an answer on June 7, 2026 at 9:48 pm
    // If there are 2 or more children 
    if($('.row-wrapper').children('.box').length >= 2){
        // add a class
        $('.row-wrapper .box').addClass("foo");
    }
    

    Something like the above should work.

    EDIT: Since wirey suggests there may be more than one .row-wrapper – which is a valid point, we can do something like this:

    // Loop through each .row-wrapper
    $(".row-wrapper").each(function(){
        // If there are 2 or more children
        if($(this).children('.box').length >= 2){
            // Find .box elements within $(this), and add a class.
            $(this).find('.box').addClass('foo');
        }
    });
    

    JSFiddle provided by Jared: http://jsfiddle.net/zqyKn/

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

Sidebar

Related Questions

i have the following code: HTML <div id=step-holder> <div class=step-no>1</div> <div class=step-dark-left><a href=#>Basic details</a></div>
If I have the following basic C++ program: #include <iostream> using namespace std; class
I have the following mark up with a basic and advanced search divs. <div
I have HTML something like this: <table> <tr> <td><div class='record'>Record Link</div></td> <td><div class='delete' style='display:none;'>Delete
consider the following html structure: <div> <div class=top> <div id=id1>123</div> <div> <div class=top> <div
Considering the following html: <div id=test data-test='[foo, bar]'></div> and the following javascript: var dataValue
Say I have the following basic if-statement: if (A ~= 0) % do something
I have been following a tutorial on how to write a basic tile map
I might have pretty basic question about regex. I have the following regex, which
Probably a very basic beginner question. Imagine the following situation: I have an ASP.NET

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.