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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T23:16:26+00:00 2026-05-19T23:16:26+00:00

I have 2 containers, one inside the other, and I’m trying to fill the

  • 0

I have 2 containers, one inside the other, and I’m trying to fill the inner container with elements on document.ready so it’s width is almost equal to the outer’s div width.

It works perfectly with “if” statement on window.resize, but since I need to fill the div on document.ready I’m trying to use “while” and it doesn’t work. Why?

Here is the HTML:

<style>
    #outer {float: left; width: 500px; background: grey}
    #inner {float: left; width: auto;}
    li {float: left; margin: 0 10px}
</style>


<div id="outer">
    <ul id="inner">
        <li></li>
        <li></li>
        <li></li>
    </ul>
</div>

​

…and JS:

function width_check() {
    var ddd = $("#outer").width() - $("#inner").width();
    var sss = 0;

    if (ddd > 100) {
        sss = 1;
    } else { sss = 0 };}​


$(document).ready function() {
    width_check();

    while (sss = 1) {
        $("#inner").append('<li></li>');
        width_check();
                    }        }
  • 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-19T23:16:26+00:00Added an answer on May 19, 2026 at 11:16 pm

    I think you have a scope problem here.

    You have a function that defines var sss = 0. But the check of $(document).ready has its own sss. sss is undefined in this function. Try something like:

    function width_check()
    {
        var ddd = $("#outer").width() - $("#inner").width();
        return ddd > 100;
    }​
    
    
    $(document).ready( function() // check the extra brackets around the function.
    {
        while(width_check()) // check the width every time
        {
            $("#inner").append('<li></li>');
        }       
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a UIView container that has two UIImageView s inside it, one partially
I have a couple of div elements contained in one container div , and
HI, I have container movieclip and one mask layer with the height and width
I have a div position relative (id container) and inside it i have other
I have one big container (div) and one header div inside of it. It
I have two divs inside a container div. One need to float left the
I have a web page with one big container for the entire page. Inside
I have a container div with a max-width and a max-height . Inside the
I have two <div> tags inside a container. one of them floating right and
I try to create a div with other divs inside: one container div, one

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.