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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T18:22:21+00:00 2026-06-05T18:22:21+00:00

How can have a div which contain multiple multiple div it may 4-6-8 how

  • 0

How can have a div which contain multiple multiple div it may 4-6-8 how can i fit them on page load using Jquery.

<div id="main">
 <div class="box"></div>
 <div class="box"></div>
 <div class="box"></div>
 <div class="box"></div>
</div>

I want to create a jquery function which can fit child div to parent div by arresting their height and width on page load.

  • 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-05T18:22:22+00:00Added an answer on June 5, 2026 at 6:22 pm

    I’m going to take a stab, and hope that what I think you want is what you actually want. I assume you want to insert a dynamic number of <div class="box"> elements into the <div id="main"> element when the page has loaded. If that is the case, this should work:

    HTML

    <div id="main"></div>
    

    jQuery

    function createBoxes(numberOfBoxes) {
        var $box = $('<div/>').addClass('box');
        var $container = $('#main');
        for(var i = 1; i <= numberOfBoxes; i++) {
            $container.append($box.clone().text(i));   
        }
    }
    
    $(function() { // calls createBoxes() when the DOM is ready
                   // shortened version of $(document).ready(function() {
        createBoxes(4);
    });
    

    DEMO

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

Sidebar

Related Questions

So I have a Div containing an iframe that I can Clone using JQuery.
I have a div <div id=ab> which contain a text field <input type=text class=a
I have this code which can display drop down in div tag of html.
I have a div having a css class MyClass. Inside this div, I can
how can i select the current link via jquery if I have a div
I have code that uses jquery.slideup and jquery.slidedown How can i know that div
I have a series of DIVs on a page which each contain a nested
I have a page which has DIVs which contain short phrases (one-two words) of
I have a page which will contain 4 static divs with IDs. I will
say I have layout like so: <div id=main> <div id=NormalContent> {some content which is

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.